client_test.go 1000 B

1234567891011121314151617181920212223242526272829303132
  1. package huawei
  2. import (
  3. "testing"
  4. "time"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_Push(t *testing.T) {
  8. Convey("push huawei", t, func() {
  9. // ac, err := NewAccess("10125085", "iejq6hn3ds3d4neq1m21v443lmbm31gs")
  10. // if err != nil {
  11. // t.Fatal(err)
  12. // } else {
  13. // t.Log(ac)
  14. // }
  15. // return
  16. ac := &Access{
  17. AppID: "10125085",
  18. Token: "CFrF0b079efz2JUoDNBs1lwk9wtL4LfxExYqZvM3lAuDAeZcytQS3CPjYO6qMv9h+6FJoKrGIsQEwcKOmODdeg==",
  19. Expire: 1522913725,
  20. }
  21. palyod := NewMessage().SetContent("huawei-content").SetTitle("huawei-title").SetCustomize("task_id", "123").SetCustomize("scheme", "bilibili://search/你好").SetIcon("http://pic.qiantucdn.com/58pic/12/38/18/13758PIC4GV.jpg")
  22. c := NewClient("tv.danmaku.bili", ac, time.Minute)
  23. // tokens := []string{"0866090037077934300001050400CN01"}
  24. tokens := []string{"1", "2", ""}
  25. res, err := c.Push(palyod, tokens, time.Now().Add(time.Hour))
  26. So(err, ShouldBeNil)
  27. t.Logf("huawei push res(%+v)", res)
  28. })
  29. }