push_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package push
  2. import (
  3. "testing"
  4. "fmt"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDao_CallPush(t *testing.T) {
  8. Convey("Http error", t, WithDao(func(d *Dao) {
  9. httpMock("POST", d.c.Cfg.Push.URL).Reply(-400).JSON("")
  10. err := d.CallPush(ctx, "ios", "", "")
  11. So(err, ShouldNotBeNil)
  12. fmt.Println(err)
  13. }))
  14. Convey("Business Code error", t, WithDao(func(d *Dao) {
  15. httpMock("POST", d.c.Cfg.Push.URL).Reply(200).JSON(`{"code":-400}"`)
  16. err := d.CallPush(ctx, "ios", "", "")
  17. So(err, ShouldNotBeNil)
  18. fmt.Println(err)
  19. }))
  20. Convey("Everything is fine", t, WithDao(func(d *Dao) {
  21. httpMock("POST", d.c.Cfg.Push.URL).Reply(200).JSON(`{"code" : 0}`)
  22. err := d.CallPush(ctx, "ios", "", "")
  23. So(err, ShouldBeNil)
  24. }))
  25. }
  26. func TestDao_DiffFinish(t *testing.T) {
  27. Convey("TestDao_DiffFinish", t, WithDao(func(d *Dao) {
  28. data, err := d.DiffFinish(ctx, "57")
  29. So(err, ShouldBeNil)
  30. So(data, ShouldBeTrue)
  31. }))
  32. }
  33. func TestDao_PushMsg(t *testing.T) {
  34. Convey("TestDao_DiffFinish", t, WithDao(func(d *Dao) {
  35. data, err := d.PushMsg(ctx, "57")
  36. fmt.Println(data)
  37. So(err, ShouldBeNil)
  38. So(data, ShouldNotBeNil)
  39. }))
  40. }
  41. func TestDao_Platform(t *testing.T) {
  42. Convey("TestDao_Platform", t, WithDao(func(d *Dao) {
  43. data, err := d.Platform(ctx, "77")
  44. fmt.Println(data)
  45. So(err, ShouldBeNil)
  46. So(data, ShouldNotBeNil)
  47. }))
  48. }