mcn_test.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/admin/main/mcn/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestServiceMcnSignEntry(t *testing.T) {
  10. convey.Convey("McnSignEntry", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. arg = &model.MCNSignEntryReq{}
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. err := s.McnSignEntry(c, arg)
  17. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestServiceMcnSignList(t *testing.T) {
  24. convey.Convey("McnSignList", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. arg = &model.MCNSignStateReq{}
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. res, err := s.McnSignList(c, arg)
  31. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(res, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestServiceMcnSignOP(t *testing.T) {
  39. convey.Convey("McnSignOP", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. arg = &model.MCNSignStateOpReq{}
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. err := s.McnSignOP(c, arg)
  46. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. })
  49. })
  50. })
  51. }
  52. func TestServiceMcnUPReviewList(t *testing.T) {
  53. convey.Convey("McnUPReviewList", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. arg = &model.MCNUPStateReq{}
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. res, err := s.McnUPReviewList(c, arg)
  60. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. ctx.So(res, convey.ShouldNotBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestServiceMcnUPOP(t *testing.T) {
  68. convey.Convey("McnUPOP", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. arg = &model.MCNUPStateOpReq{}
  72. )
  73. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  74. err := s.McnUPOP(c, arg)
  75. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldBeNil)
  77. })
  78. })
  79. })
  80. }
  81. func TestServiceMcnPermitOP(t *testing.T) {
  82. convey.Convey("McnPermitOP", t, func(ctx convey.C) {
  83. var (
  84. c = context.Background()
  85. arg = &model.MCNSignPermissionReq{}
  86. )
  87. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  88. err := s.McnPermitOP(c, arg)
  89. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  90. ctx.So(err, convey.ShouldBeNil)
  91. })
  92. })
  93. })
  94. }
  95. func TestServicegetPermitOpenOrClosed(t *testing.T) {
  96. convey.Convey("getPermitOpenOrClosed", t, func(ctx convey.C) {
  97. var (
  98. a = uint32(5)
  99. b = uint32(5)
  100. )
  101. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  102. open, closed := s.getPermitOpenOrClosed(a, b)
  103. ctx.Convey("Then open,closed should not be nil.", func(ctx convey.C) {
  104. ctx.So(closed, convey.ShouldNotBeNil)
  105. ctx.So(open, convey.ShouldNotBeNil)
  106. })
  107. })
  108. })
  109. }
  110. func TestServicegetUpPermitString(t *testing.T) {
  111. convey.Convey("getPermitOpenOrClosed", t, func(ctx convey.C) {
  112. var (
  113. a = uint32(5)
  114. )
  115. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  116. ps := s.getUpPermitString(a)
  117. ctx.Convey("Then open,closed should not be nil.", func(ctx convey.C) {
  118. ctx.So(ps, convey.ShouldNotBeNil)
  119. })
  120. })
  121. })
  122. }
  123. func TestServiceMcnUPPermitList(t *testing.T) {
  124. convey.Convey("McnUPPermitList", t, func(ctx convey.C) {
  125. var (
  126. c = context.Background()
  127. arg = &model.MCNUPPermitStateReq{}
  128. )
  129. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  130. res, err := s.McnUPPermitList(c, arg)
  131. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  132. ctx.So(err, convey.ShouldBeNil)
  133. ctx.So(res, convey.ShouldNotBeNil)
  134. })
  135. })
  136. })
  137. }
  138. func TestServiceMcnUPPermitOP(t *testing.T) {
  139. convey.Convey("McnUPPermitOP", t, func(ctx convey.C) {
  140. var (
  141. c = context.Background()
  142. arg = &model.MCNUPPermitOPReq{}
  143. )
  144. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  145. err := s.McnUPPermitOP(c, arg)
  146. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  147. ctx.So(err, convey.ShouldBeNil)
  148. })
  149. })
  150. })
  151. }
  152. func TestServiceMCNList(t *testing.T) {
  153. convey.Convey("MCNList", t, func(ctx convey.C) {
  154. var (
  155. c = context.Background()
  156. arg = &model.MCNListReq{State: -1}
  157. )
  158. arg.MCNMID = 12345
  159. arg.Export = "csv"
  160. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  161. res, err := s.MCNList(c, arg)
  162. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  163. for k, v := range res.List {
  164. fmt.Printf("re[%d]:%+v", k, v)
  165. }
  166. ctx.So(err, convey.ShouldBeNil)
  167. ctx.So(res, convey.ShouldNotBeNil)
  168. })
  169. })
  170. })
  171. }
  172. func TestServiceMCNPayEdit(t *testing.T) {
  173. convey.Convey("MCNPayEdit", t, func(ctx convey.C) {
  174. var (
  175. c = context.Background()
  176. arg = &model.MCNPayEditReq{}
  177. )
  178. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  179. err := s.MCNPayEdit(c, arg)
  180. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  181. ctx.So(err, convey.ShouldBeNil)
  182. })
  183. })
  184. })
  185. }
  186. func TestServiceMCNPayStateEdit(t *testing.T) {
  187. convey.Convey("MCNPayStateEdit", t, func(ctx convey.C) {
  188. var (
  189. c = context.Background()
  190. arg = &model.MCNPayStateEditReq{ID: 1, MCNMID: 212895899, SignID: 1}
  191. )
  192. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  193. err := s.MCNPayStateEdit(c, arg)
  194. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  195. ctx.So(err, convey.ShouldBeNil)
  196. })
  197. })
  198. })
  199. }
  200. func TestServiceMCNStateEdit(t *testing.T) {
  201. convey.Convey("MCNStateEdit", t, func(ctx convey.C) {
  202. var (
  203. c = context.Background()
  204. arg = &model.MCNStateEditReq{ID: 1, MCNMID: 1212, Action: model.McnAccountRestore}
  205. )
  206. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  207. err := s.MCNStateEdit(c, arg)
  208. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  209. ctx.So(err, convey.ShouldBeNil)
  210. })
  211. })
  212. })
  213. }
  214. func TestServiceMCNRenewal(t *testing.T) {
  215. convey.Convey("MCNRenewal", t, func(ctx convey.C) {
  216. var (
  217. c = context.Background()
  218. arg = &model.MCNRenewalReq{ID: 5, MCNMID: 27515432, BeginDate: "2018-09-22", EndDate: "2019-09-23", ContractLink: "ContractLink"}
  219. )
  220. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  221. err := s.MCNRenewal(c, arg)
  222. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  223. ctx.So(err, convey.ShouldBeNil)
  224. })
  225. })
  226. })
  227. }
  228. func TestServiceMCNInfo(t *testing.T) {
  229. convey.Convey("MCNInfo", t, func(ctx convey.C) {
  230. var (
  231. c = context.Background()
  232. arg = &model.MCNInfoReq{ID: 9}
  233. )
  234. arg.MCNMID = 27515432
  235. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  236. res, err := s.MCNInfo(c, arg)
  237. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  238. fmt.Println(res)
  239. ctx.So(err, convey.ShouldBeNil)
  240. ctx.So(res, convey.ShouldNotBeNil)
  241. })
  242. })
  243. })
  244. }
  245. func TestServiceMCNUPList(t *testing.T) {
  246. convey.Convey("McnUPList", t, func(ctx convey.C) {
  247. var (
  248. c = context.Background()
  249. arg = &model.MCNUPListReq{SignID: 3, State: -1, SortFansCountActive: "asc"}
  250. )
  251. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  252. res, err := s.MCNUPList(c, arg)
  253. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  254. for k, v := range res.List {
  255. fmt.Printf("re[%d]:%+v \n", k, v)
  256. }
  257. ctx.So(err, convey.ShouldBeNil)
  258. ctx.So(res, convey.ShouldNotBeNil)
  259. })
  260. })
  261. })
  262. }
  263. func TestServiceMCNUPStateEdit(t *testing.T) {
  264. convey.Convey("MCNUPStateEdit", t, func(ctx convey.C) {
  265. var (
  266. c = context.Background()
  267. arg = &model.MCNUPStateEditReq{ID: 1, SignID: 1}
  268. )
  269. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  270. err := s.MCNUPStateEdit(c, arg)
  271. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  272. ctx.So(err, convey.ShouldBeNil)
  273. })
  274. })
  275. })
  276. }