api_test.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. package elec
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestElecUserInfo(t *testing.T) {
  8. var (
  9. c = context.TODO()
  10. mid = int64(2089809)
  11. ip = "127.0.0.1"
  12. )
  13. convey.Convey("UserInfo", t, func(ctx convey.C) {
  14. st, err := d.UserInfo(c, mid, ip)
  15. ctx.Convey("Then err should be nil.st should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(st, convey.ShouldNotBeNil)
  18. })
  19. })
  20. }
  21. func TestElecUserUpdate(t *testing.T) {
  22. var (
  23. c = context.TODO()
  24. mid = int64(2089809)
  25. st = int8(1)
  26. ip = "127.0.0.1"
  27. )
  28. convey.Convey("UserUpdate", t, func(ctx convey.C) {
  29. u, err := d.UserUpdate(c, mid, st, ip)
  30. ctx.Convey("Then err should be nil.u should not be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. ctx.So(u, convey.ShouldNotBeNil)
  33. })
  34. })
  35. }
  36. func TestElecArcUpdate(t *testing.T) {
  37. var (
  38. c = context.TODO()
  39. mid = int64(2089809)
  40. aid = int64(10106491)
  41. st = int8(1)
  42. ip = "127.0.0.1"
  43. )
  44. convey.Convey("ArcUpdate", t, func(ctx convey.C) {
  45. err := d.ArcUpdate(c, mid, aid, st, ip)
  46. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. })
  49. })
  50. }
  51. func TestElecNotify(t *testing.T) {
  52. var (
  53. c = context.TODO()
  54. ip = ""
  55. )
  56. convey.Convey("Notify", t, func(ctx convey.C) {
  57. nt, err := d.Notify(c, ip)
  58. ctx.Convey("Then err should be nil.nt should not be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. ctx.So(nt, convey.ShouldNotBeNil)
  61. })
  62. })
  63. }
  64. func TestElecStatus(t *testing.T) {
  65. var (
  66. c = context.TODO()
  67. mid = int64(2089809)
  68. ip = "127.0.0.1"
  69. )
  70. convey.Convey("Status", t, func(ctx convey.C) {
  71. st, err := d.Status(c, mid, ip)
  72. ctx.Convey("Then err should be nil.st should not be nil.", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. ctx.So(st, convey.ShouldNotBeNil)
  75. })
  76. })
  77. }
  78. func TestElecUpStatus(t *testing.T) {
  79. var (
  80. c = context.TODO()
  81. mid = int64(2089809)
  82. spday = int(1)
  83. ip = "127.0.0.1"
  84. )
  85. convey.Convey("UpStatus", t, func(ctx convey.C) {
  86. err := d.UpStatus(c, mid, spday, ip)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. }
  92. func TestElecRecentRank(t *testing.T) {
  93. var (
  94. c = context.TODO()
  95. mid = int64(2089809)
  96. size = int64(10)
  97. ip = "127.0.0.1"
  98. )
  99. convey.Convey("RecentRank", t, func(ctx convey.C) {
  100. rec, err := d.RecentRank(c, mid, size, ip)
  101. ctx.Convey("Then err should be nil.rec should not be nil.", func(ctx convey.C) {
  102. ctx.So(err, convey.ShouldBeNil)
  103. ctx.So(rec, convey.ShouldNotBeNil)
  104. })
  105. })
  106. }
  107. func TestElecCurrentRank(t *testing.T) {
  108. var (
  109. c = context.TODO()
  110. mid = int64(2089809)
  111. ip = "127.0.0.1"
  112. )
  113. convey.Convey("CurrentRank", t, func(ctx convey.C) {
  114. cur, err := d.CurrentRank(c, mid, ip)
  115. ctx.Convey("Then err should be nil.cur should not be nil.", func(ctx convey.C) {
  116. ctx.So(err, convey.ShouldBeNil)
  117. ctx.So(cur, convey.ShouldNotBeNil)
  118. })
  119. })
  120. }
  121. func TestElecTotalRank(t *testing.T) {
  122. var (
  123. c = context.TODO()
  124. mid = int64(2089809)
  125. ip = "127.0.0.1"
  126. )
  127. convey.Convey("TotalRank", t, func(ctx convey.C) {
  128. tol, err := d.TotalRank(c, mid, ip)
  129. ctx.Convey("Then err should be nil.tol should not be nil.", func(ctx convey.C) {
  130. ctx.So(err, convey.ShouldBeNil)
  131. ctx.So(tol, convey.ShouldNotBeNil)
  132. })
  133. })
  134. }
  135. func TestElecDailyBill(t *testing.T) {
  136. var (
  137. c = context.TODO()
  138. mid = int64(2089809)
  139. pn = int(1)
  140. ps = int(10)
  141. ip = "127.0.0.1"
  142. begin = "2018-01-04"
  143. end = "2019-01-04"
  144. )
  145. convey.Convey("DailyBill", t, func(ctx convey.C) {
  146. bl, err := d.DailyBill(c, mid, pn, ps, begin, end, ip)
  147. ctx.Convey("Then err should be nil.bl should not be nil.", func(ctx convey.C) {
  148. ctx.So(err, convey.ShouldBeNil)
  149. ctx.So(bl, convey.ShouldNotBeNil)
  150. })
  151. })
  152. }
  153. func TestElecBalance(t *testing.T) {
  154. var (
  155. c = context.TODO()
  156. mid = int64(2089809)
  157. ip = "127.0.0.1"
  158. )
  159. convey.Convey("Balance", t, func(ctx convey.C) {
  160. bal, err := d.Balance(c, mid, ip)
  161. ctx.Convey("Then err should be nil.bal should not be nil.", func(ctx convey.C) {
  162. ctx.So(err, convey.ShouldBeNil)
  163. ctx.So(bal, convey.ShouldNotBeNil)
  164. })
  165. })
  166. }
  167. func TestElecRecentElec(t *testing.T) {
  168. var (
  169. c = context.TODO()
  170. mid = int64(2089809)
  171. pn = int(1)
  172. ps = int(10)
  173. ip = "127.0.0.1"
  174. )
  175. convey.Convey("RecentElec", t, func(ctx convey.C) {
  176. rec, err := d.RecentElec(c, mid, pn, ps, ip)
  177. ctx.Convey("Then err should be nil.rec should not be nil.", func(ctx convey.C) {
  178. ctx.So(err, convey.ShouldBeNil)
  179. ctx.So(rec, convey.ShouldNotBeNil)
  180. })
  181. })
  182. }
  183. func TestElecRemarkList(t *testing.T) {
  184. var (
  185. c = context.TODO()
  186. mid = int64(2089809)
  187. pn = int(1)
  188. ps = int(10)
  189. begin = ""
  190. end = ""
  191. ip = "127.0.0.1"
  192. )
  193. convey.Convey("RemarkList", t, func(ctx convey.C) {
  194. rec, err := d.RemarkList(c, mid, pn, ps, begin, end, ip)
  195. ctx.Convey("Then err should be nil.rec should not be nil.", func(ctx convey.C) {
  196. ctx.So(err, convey.ShouldBeNil)
  197. ctx.So(rec, convey.ShouldNotBeNil)
  198. })
  199. })
  200. }
  201. func TestElecRemarkDetail(t *testing.T) {
  202. var (
  203. c = context.TODO()
  204. mid = int64(2089809)
  205. id = int64(0)
  206. ip = "127.0.0.1"
  207. )
  208. convey.Convey("RemarkDetail", t, func(ctx convey.C) {
  209. re, err := d.RemarkDetail(c, mid, id, ip)
  210. ctx.Convey("Then err should be nil.re should not be nil.", func(ctx convey.C) {
  211. ctx.So(err, convey.ShouldBeNil)
  212. ctx.So(re, convey.ShouldNotBeNil)
  213. })
  214. })
  215. }
  216. func TestElecRemark(t *testing.T) {
  217. var (
  218. c = context.TODO()
  219. mid = int64(2089809)
  220. id = int64(0)
  221. msg = ""
  222. ak = ""
  223. ck = ""
  224. ip = "127.0.0.1"
  225. )
  226. convey.Convey("Remark", t, func(ctx convey.C) {
  227. status, err := d.Remark(c, mid, id, msg, ak, ck, ip)
  228. ctx.Convey("Then err should be nil.status should not be nil.", func(ctx convey.C) {
  229. ctx.So(err, convey.ShouldBeNil)
  230. ctx.So(status, convey.ShouldNotBeNil)
  231. })
  232. })
  233. }