api_test.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package growup
  2. import (
  3. "context"
  4. "go-common/library/ecode"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestGrowupUpStatus(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. mid = int64(2089809)
  12. ip = "127.0.0.1"
  13. )
  14. convey.Convey("UpStatus", t, func(ctx convey.C) {
  15. us, err := d.UpStatus(c, mid, ip)
  16. ctx.Convey("Then err should be nil.us should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
  18. ctx.So(us, convey.ShouldNotBeNil)
  19. })
  20. })
  21. }
  22. func TestGrowupUpInfo(t *testing.T) {
  23. var (
  24. c = context.TODO()
  25. mid = int64(2089809)
  26. ip = "127.0.0.1"
  27. )
  28. convey.Convey("UpInfo", t, func(ctx convey.C) {
  29. ui, err := d.UpInfo(c, mid, ip)
  30. ctx.Convey("Then err should be nil.ui should not be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldNotBeNil)
  32. ctx.So(ui, convey.ShouldBeNil)
  33. })
  34. })
  35. }
  36. func TestGrowupJoin(t *testing.T) {
  37. var (
  38. c = context.TODO()
  39. mid = int64(0)
  40. accTy = int(0)
  41. signTy = int(0)
  42. ip = ""
  43. )
  44. convey.Convey("Join", t, func(ctx convey.C) {
  45. err := d.Join(c, mid, accTy, signTy, ip)
  46. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
  48. })
  49. })
  50. }
  51. func TestGrowupQuit(t *testing.T) {
  52. var (
  53. c = context.TODO()
  54. mid = int64(2089809)
  55. ip = "127.0.0.1"
  56. )
  57. convey.Convey("Quit1", t, func(ctx convey.C) {
  58. httpMock("POST", d.quitURL).Reply(200).JSON(`{"code":20008}`)
  59. err := d.Quit(c, mid, ip)
  60. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldNotBeNil)
  62. })
  63. })
  64. convey.Convey("Quit2", t, func(ctx convey.C) {
  65. httpMock("POST", d.quitURL).Reply(502)
  66. err := d.Quit(c, mid, ip)
  67. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldNotBeNil)
  69. })
  70. })
  71. }
  72. func TestGrowupSummary(t *testing.T) {
  73. var (
  74. c = context.TODO()
  75. mid = int64(2089809)
  76. ip = "127.0.0.1"
  77. )
  78. convey.Convey("Summary", t, func(ctx convey.C) {
  79. sm, err := d.Summary(c, mid, ip)
  80. ctx.Convey("Then err should be nil.sm should not be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
  82. ctx.So(sm, convey.ShouldBeNil)
  83. })
  84. })
  85. }
  86. func TestGrowupStat(t *testing.T) {
  87. var (
  88. c = context.TODO()
  89. mid = int64(2089809)
  90. ip = "127.0.0.1"
  91. )
  92. convey.Convey("Stat", t, func(ctx convey.C) {
  93. st, err := d.Stat(c, mid, ip)
  94. ctx.Convey("Then err should be nil.st should not be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
  96. ctx.So(st, convey.ShouldBeNil)
  97. })
  98. })
  99. }
  100. func TestGrowupIncomeList(t *testing.T) {
  101. var (
  102. c = context.TODO()
  103. mid = int64(2089809)
  104. ty = int(0)
  105. pn = int(1)
  106. ps = int(10)
  107. ip = "127.0.0.1"
  108. )
  109. convey.Convey("IncomeList", t, func(ctx convey.C) {
  110. il, err := d.IncomeList(c, mid, ty, pn, ps, ip)
  111. ctx.Convey("Then err should be nil.il should not be nil.", func(ctx convey.C) {
  112. ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
  113. ctx.So(il, convey.ShouldBeNil)
  114. })
  115. })
  116. }
  117. func TestGrowupBreachList(t *testing.T) {
  118. var (
  119. c = context.TODO()
  120. mid = int64(2089809)
  121. pn = int(1)
  122. ps = int(10)
  123. ip = "127.0.0.1"
  124. )
  125. convey.Convey("BreachList", t, func(ctx convey.C) {
  126. bl, err := d.BreachList(c, mid, pn, ps, ip)
  127. ctx.Convey("Then err should be nil.bl should not be nil.", func(ctx convey.C) {
  128. ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
  129. ctx.So(bl, convey.ShouldBeNil)
  130. })
  131. })
  132. }