push_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package service
  2. import (
  3. "context"
  4. "encoding/json"
  5. "testing"
  6. "time"
  7. xtime "go-common/library/time"
  8. "go-common/app/admin/main/vip/model"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestService_GetPushData(t *testing.T) {
  12. Convey("getpushData should be nil", t, func() {
  13. id := 1
  14. res, err := s.GetPushData(context.TODO(), int64(id))
  15. bytes, _ := json.Marshal(res)
  16. t.Logf("%+v", string(bytes))
  17. So(err, ShouldBeNil)
  18. })
  19. }
  20. func TestService_SavePushData(t *testing.T) {
  21. Convey("save push data should be nil", t, func() {
  22. arg := new(model.VipPushData)
  23. arg.ID = 1
  24. arg.GroupName = "test01"
  25. arg.Title = "title"
  26. arg.Content = "content"
  27. arg.Platform = "[{\"name\":\"Android\",\"condition\":\"=\",\"build\":1},{\"name\":\"iPhone\",\"condition\":\"<=\",\"build\":2},{\"name\":\"iPad\",\"condition\":\"=\",\"build\":3}]"
  28. arg.LinkType = 10
  29. arg.ExpiredDayStart = -1
  30. arg.ExpiredDayEnd = 10
  31. arg.EffectStartDate = xtime.Time(time.Now().Unix())
  32. arg.EffectEndDate = xtime.Time(time.Now().AddDate(0, 0, 7).Unix())
  33. arg.PushStartTime = "18:00:00"
  34. arg.PushEndTime = "20:00:00"
  35. err := s.SavePushData(context.TODO(), arg)
  36. So(err, ShouldBeNil)
  37. })
  38. }
  39. func TestService_PushDatas(t *testing.T) {
  40. Convey("push data should be nil", t, func() {
  41. arg := new(model.ArgPushData)
  42. arg.Status = 0
  43. arg.ProgressStatus = 0
  44. res, count, err := s.PushDatas(context.TODO(), arg)
  45. bytes, _ := json.Marshal(res)
  46. t.Logf("res(%+v) count(%v) ", string(bytes), count)
  47. So(err, ShouldBeNil)
  48. })
  49. }