You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 satır
2.1KB

  1. package main
  2. import (
  3. "fmt"
  4. "math/rand"
  5. "testing"
  6. "time"
  7. )
  8. var toUser = "oUN420bxqFqlx0ZQHciUOesZO3PE"
  9. func randinit() {
  10. rand.Seed(time.Now().UnixNano())
  11. }
  12. var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
  13. func RandStringRunes(n int) string {
  14. b := make([]rune, n)
  15. for i := range b {
  16. b[i] = letterRunes[rand.Intn(len(letterRunes))]
  17. }
  18. return string(b)
  19. }
  20. func TestSendTxt(t *testing.T) {
  21. SetupConfig()
  22. msg := fmt.Sprintf("测试消息, %s ", time.Now().String())
  23. randinit()
  24. msg = RandStringRunes(2048)
  25. kfSendTxt(toUser, msg)
  26. }
  27. func TestSendPic(t *testing.T) {
  28. SetupConfig()
  29. kfSendPic(toUser, "media_for_test/200x200.png")
  30. }
  31. func TestSendVoice(t *testing.T) {
  32. SetupConfig()
  33. kfSendVoice(toUser, "media_for_test/example.amr")
  34. //kfSendVoiceByMediaID(toUser, "8Tc-pcFxEMtbO6T71AaL0A16taJUpwolXpB06mBBfaPZ68R3__1nN7HuZAUyW8xR")
  35. }
  36. func TestSendVideo(t *testing.T) {
  37. SetupConfig()
  38. //kfSendVideo(toUser, "media_for_test/video.mp4", "测试时品", "普通描述", "media_for_test/music-thumb.jpg")
  39. kfSendVideoByMediaID(toUser,
  40. "xwcgPCY8TRHP_PIy_4qunL8ad9mq7vD3hc9-OpNVRKG1qTwjKkQHN4GKb9mAcJ3J",
  41. "视频测试标题",
  42. "视频测试描述信息",
  43. "6QKTfDxkQS2ACDzVhY0ddKjlIsBTyB6cf9fFWG88uwbJ0Mlh_gSIMxnaGvdqU4y0")
  44. }
  45. func TestSendMusic(t *testing.T) {
  46. SetupConfig()
  47. tID := uploadThumb("media_for_test/music-thumb.jpg")
  48. description := fmt.Sprintf("音乐描述 %s", time.Now().String())
  49. kfSendMusic(toUser,
  50. "音乐标题",
  51. description,
  52. tID,
  53. "https://biukop.com.au/music.mp3",
  54. "https://biukop.com.au/music.mp3")
  55. }
  56. func TestSendArticle(t *testing.T) {
  57. SetupConfig()
  58. articles := []sendNewsArticle{}
  59. for i := 1; i <= 8; i++ {
  60. a := sendNewsArticle{}
  61. a.Description = fmt.Sprintf("描述 %d ", i)
  62. a.PicURL = "https://placehold.it/360x200.jpg"
  63. a.Title = fmt.Sprintf("标题 %d", i)
  64. a.URL = fmt.Sprintf("https://placehold.it/%dx%d", i*100, i*100)
  65. articles = append(articles, a)
  66. }
  67. kfSendNews(toUser, "总标题", "总描述", articles)
  68. }
  69. func TestSendArticleByMediaID(t *testing.T) {
  70. SetupConfig()
  71. kfSendMPNews(toUser, "e2iNEiSxCX5TV1WbFd0TQP4_MKtjcY1q-4UPIZFrHhw")
  72. }