package main import ( "fmt" "math/rand" "testing" "time" ) var toUser = "oUN420bxqFqlx0ZQHciUOesZO3PE" func randinit() { rand.Seed(time.Now().UnixNano()) } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } func TestSendTxt(t *testing.T) { SetupConfig() msg := fmt.Sprintf("测试消息, %s ", time.Now().String()) randinit() msg = RandStringRunes(2048) kfSendTxt(toUser, msg) } func TestSendPic(t *testing.T) { SetupConfig() kfSendPic(toUser, "media_for_test/200x200.png") } func TestSendVoice(t *testing.T) { SetupConfig() kfSendVoice(toUser, "media_for_test/example.amr") //kfSendVoiceByMediaID(toUser, "8Tc-pcFxEMtbO6T71AaL0A16taJUpwolXpB06mBBfaPZ68R3__1nN7HuZAUyW8xR") } func TestSendVideo(t *testing.T) { SetupConfig() //kfSendVideo(toUser, "media_for_test/video.mp4", "测试时品", "普通描述", "media_for_test/music-thumb.jpg") kfSendVideoByMediaID(toUser, "xwcgPCY8TRHP_PIy_4qunL8ad9mq7vD3hc9-OpNVRKG1qTwjKkQHN4GKb9mAcJ3J", "视频测试标题", "视频测试描述信息", "6QKTfDxkQS2ACDzVhY0ddKjlIsBTyB6cf9fFWG88uwbJ0Mlh_gSIMxnaGvdqU4y0") } func TestSendMusic(t *testing.T) { SetupConfig() tID := uploadThumb("media_for_test/music-thumb.jpg") description := fmt.Sprintf("音乐描述 %s", time.Now().String()) kfSendMusic(toUser, "音乐标题", description, tID, "https://biukop.com.au/music.mp3", "https://biukop.com.au/music.mp3") } func TestSendArticle(t *testing.T) { SetupConfig() articles := []sendNewsArticle{} for i := 1; i <= 8; i++ { a := sendNewsArticle{} a.Description = fmt.Sprintf("描述 %d ", i) a.PicURL = "https://placehold.it/360x200.jpg" a.Title = fmt.Sprintf("标题 %d", i) a.URL = fmt.Sprintf("https://placehold.it/%dx%d", i*100, i*100) articles = append(articles, a) } kfSendNews(toUser, "总标题", "总描述", articles) } func TestSendArticleByMediaID(t *testing.T) { SetupConfig() kfSendMPNews(toUser, "e2iNEiSxCX5TV1WbFd0TQP4_MKtjcY1q-4UPIZFrHhw") }