task_test.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. package newcomer
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/creative/model/newcomer"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestNewcomergetTableName(t *testing.T) {
  9. convey.Convey("getTableName", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(27515308)
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := getTableName(mid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestNewcomerUserTaskBind(t *testing.T) {
  22. convey.Convey("UserTaskBind", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. mid = int64(27515308)
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. res, err := d.UserTaskBind(c, mid)
  29. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. ctx.So(res, convey.ShouldNotBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestNewcomerIsRewardReceived(t *testing.T) {
  37. convey.Convey("IsRewardReceived", t, func(ctx convey.C) {
  38. var (
  39. c = context.Background()
  40. mid = int64(27515308)
  41. rid = int64(1)
  42. rewardType = int8(1)
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. res, err := d.IsRewardReceived(c, mid, rid, rewardType)
  46. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. ctx.So(res, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestNewcomerRewardReceivedGroup(t *testing.T) {
  54. convey.Convey("RewardReceivedGroup", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. mid = int64(27515308)
  58. ids = []int64{1, 2, 3}
  59. )
  60. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  61. res, err := d.RewardReceivedGroup(c, mid, ids)
  62. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. ctx.So(res, convey.ShouldNotBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestNewcomerGiftRewards(t *testing.T) {
  70. convey.Convey("GiftRewards", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. taskType = int8(1)
  74. )
  75. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  76. res, err := d.GiftRewards(c, taskType)
  77. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(res, convey.ShouldNotBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestNewcomerTaskGroupRewards(t *testing.T) {
  85. convey.Convey("TaskGroupRewards", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. groupID = int64(1)
  89. )
  90. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  91. res, err := d.TaskGroupRewards(c, groupID)
  92. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(res, convey.ShouldNotBeNil)
  95. })
  96. })
  97. })
  98. }
  99. func TestNewcomerRewardCompleteState(t *testing.T) {
  100. convey.Convey("RewardCompleteState", t, func(ctx convey.C) {
  101. var (
  102. c = context.Background()
  103. mid = int64(27515308)
  104. tids = []int64{1, 2, 3}
  105. )
  106. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  107. res, err := d.RewardCompleteState(c, mid, tids)
  108. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  109. ctx.So(err, convey.ShouldBeNil)
  110. ctx.So(res, convey.ShouldNotBeNil)
  111. })
  112. })
  113. })
  114. }
  115. func TestNewcomerRewardReceive(t *testing.T) {
  116. convey.Convey("RewardReceive", t, func(ctx convey.C) {
  117. var (
  118. c = context.Background()
  119. places = "(?, ?, ?, ?, ? ,?)"
  120. args = []interface{}{1, 1, 1, 1, 1, 1}
  121. )
  122. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  123. p1, err := d.RewardReceive(c, places, args)
  124. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  125. ctx.So(err, convey.ShouldBeNil)
  126. ctx.So(p1, convey.ShouldNotBeNil)
  127. })
  128. })
  129. })
  130. }
  131. func TestNewcomerRewardActivate(t *testing.T) {
  132. convey.Convey("RewardActivate", t, func(ctx convey.C) {
  133. var (
  134. c = context.Background()
  135. mid = int64(27515308)
  136. id = int64(2)
  137. )
  138. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  139. p1, err := d.RewardActivate(c, mid, id)
  140. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  141. ctx.So(err, convey.ShouldBeNil)
  142. ctx.So(p1, convey.ShouldNotBeNil)
  143. })
  144. })
  145. })
  146. }
  147. func TestNewcomerRewardReceives(t *testing.T) {
  148. convey.Convey("RewardReceives", t, func(ctx convey.C) {
  149. var (
  150. c = context.Background()
  151. mid = int64(27515308)
  152. )
  153. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  154. res, err := d.RewardReceives(c, mid)
  155. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  156. ctx.So(err, convey.ShouldBeNil)
  157. ctx.So(res, convey.ShouldNotBeNil)
  158. })
  159. })
  160. })
  161. }
  162. func TestNewcomerRewards(t *testing.T) {
  163. convey.Convey("Rewards", t, func(ctx convey.C) {
  164. var (
  165. c = context.Background()
  166. )
  167. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  168. res, err := d.Rewards(c)
  169. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  170. ctx.So(err, convey.ShouldBeNil)
  171. ctx.So(res, convey.ShouldNotBeNil)
  172. })
  173. })
  174. })
  175. }
  176. func TestNewcomerGiftRewardCount(t *testing.T) {
  177. convey.Convey("GiftRewardCount", t, func(ctx convey.C) {
  178. var (
  179. c = context.Background()
  180. mid = int64(27515308)
  181. ids = []int64{1}
  182. )
  183. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  184. res, err := d.GiftRewardCount(c, mid, ids)
  185. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  186. ctx.So(err, convey.ShouldBeNil)
  187. ctx.So(res, convey.ShouldNotBeNil)
  188. })
  189. })
  190. })
  191. }
  192. func TestNewcomerBaseRewardCount(t *testing.T) {
  193. convey.Convey("BaseRewardCount", t, func(ctx convey.C) {
  194. var (
  195. c = context.Background()
  196. mid = int64(27515308)
  197. ids = []int64{1}
  198. )
  199. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  200. res, err := d.BaseRewardCount(c, mid, ids)
  201. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  202. ctx.So(err, convey.ShouldBeNil)
  203. ctx.So(res, convey.ShouldNotBeNil)
  204. })
  205. })
  206. })
  207. }
  208. func TestNewcomerTasks(t *testing.T) {
  209. convey.Convey("Tasks", t, func(ctx convey.C) {
  210. var (
  211. c = context.Background()
  212. )
  213. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  214. res, err := d.Tasks(c)
  215. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  216. ctx.So(err, convey.ShouldBeNil)
  217. ctx.So(res, convey.ShouldNotBeNil)
  218. })
  219. })
  220. })
  221. }
  222. func TestNewcomerUserTasksByMID(t *testing.T) {
  223. convey.Convey("UserTasksByMID", t, func(ctx convey.C) {
  224. var (
  225. c = context.Background()
  226. mid = int64(27515308)
  227. )
  228. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  229. res, err := d.UserTasksByMID(c, mid)
  230. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  231. ctx.So(err, convey.ShouldBeNil)
  232. ctx.So(res, convey.ShouldNotBeNil)
  233. })
  234. })
  235. })
  236. }
  237. func TestNewcomerUpUserTask(t *testing.T) {
  238. convey.Convey("UpUserTask", t, func(ctx convey.C) {
  239. var (
  240. c = context.Background()
  241. mid = int64(27515308)
  242. tid = int64(1)
  243. )
  244. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  245. p1, err := d.UpUserTask(c, mid, tid)
  246. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  247. ctx.So(err, convey.ShouldBeNil)
  248. ctx.So(p1, convey.ShouldNotBeNil)
  249. })
  250. })
  251. })
  252. }
  253. func TestNewcomerUserTaskType(t *testing.T) {
  254. convey.Convey("UserTaskType", t, func(ctx convey.C) {
  255. var (
  256. c = context.Background()
  257. mid = int64(27515308)
  258. )
  259. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  260. res, err := d.UserTaskType(c, mid)
  261. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  262. ctx.So(err, convey.ShouldBeNil)
  263. ctx.So(res, convey.ShouldNotBeNil)
  264. })
  265. })
  266. })
  267. }
  268. func TestNewcomerAllTaskGroupRewards(t *testing.T) {
  269. convey.Convey("AllTaskGroupRewards", t, func(ctx convey.C) {
  270. var (
  271. c = context.Background()
  272. )
  273. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  274. res, err := d.AllTaskGroupRewards(c)
  275. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  276. ctx.So(err, convey.ShouldBeNil)
  277. ctx.So(res, convey.ShouldNotBeNil)
  278. })
  279. })
  280. })
  281. }
  282. func TestNewcomerAllGiftRewards(t *testing.T) {
  283. convey.Convey("AllGiftRewards", t, func(ctx convey.C) {
  284. var (
  285. c = context.Background()
  286. )
  287. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  288. res, err := d.AllGiftRewards(c)
  289. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  290. ctx.So(err, convey.ShouldBeNil)
  291. ctx.So(res, convey.ShouldNotBeNil)
  292. })
  293. })
  294. })
  295. }
  296. func TestNewcomerUserTasks(t *testing.T) {
  297. convey.Convey("UserTasks", t, func(ctx convey.C) {
  298. var (
  299. c = context.Background()
  300. mid = int64(27515308)
  301. )
  302. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  303. res, err := d.UserTasks(c, mid)
  304. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  305. ctx.So(err, convey.ShouldBeNil)
  306. ctx.So(res, convey.ShouldNotBeNil)
  307. })
  308. })
  309. })
  310. }
  311. func TestNewcomerRewardReceiveByID(t *testing.T) {
  312. convey.Convey("RewardReceiveByID", t, func(ctx convey.C) {
  313. var (
  314. c = context.Background()
  315. mid = int64(27515308)
  316. rid = int64(2)
  317. )
  318. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  319. res, err := d.RewardReceiveByID(c, mid, rid)
  320. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  321. ctx.So(err, convey.ShouldBeNil)
  322. ctx.So(res, convey.ShouldNotBeNil)
  323. })
  324. })
  325. })
  326. }
  327. func TestNewcomerTaskGroups(t *testing.T) {
  328. convey.Convey("TaskGroups", t, func(ctx convey.C) {
  329. var (
  330. c = context.Background()
  331. )
  332. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  333. res, err := d.TaskGroups(c)
  334. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  335. ctx.So(err, convey.ShouldBeNil)
  336. ctx.So(res, convey.ShouldNotBeNil)
  337. })
  338. })
  339. })
  340. }
  341. func TestNewcomerTaskRewards(t *testing.T) {
  342. convey.Convey("TaskRewards", t, func(ctx convey.C) {
  343. var (
  344. c = context.Background()
  345. )
  346. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  347. res, err := d.TaskRewards(c)
  348. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  349. ctx.So(err, convey.ShouldBeNil)
  350. ctx.So(res, convey.ShouldNotBeNil)
  351. })
  352. })
  353. })
  354. }
  355. func TestNewcomerRewardReceive2(t *testing.T) {
  356. convey.Convey("RewardReceive2", t, func(ctx convey.C) {
  357. var (
  358. c = context.Background()
  359. rrs = make([]*newcomer.RewardReceive2, 0)
  360. mid = int64(27515308)
  361. )
  362. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  363. res, err := d.RewardReceive2(c, mid, rrs)
  364. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  365. ctx.So(err, convey.ShouldBeNil)
  366. ctx.So(res, convey.ShouldNotBeNil)
  367. })
  368. })
  369. })
  370. }
  371. func TestNewcomerRewardReceiveByOldInfo(t *testing.T) {
  372. convey.Convey("RewardReceiveByOldInfo", t, func(ctx convey.C) {
  373. var (
  374. c = context.Background()
  375. mid = int64(27515308)
  376. r = &newcomer.RewardReceive{
  377. ID: 2,
  378. MID: mid,
  379. TaskGiftID: 0,
  380. TaskGroupID: 2,
  381. RewardID: 7,
  382. }
  383. )
  384. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  385. res, err := d.RewardReceiveByOldInfo(c, r)
  386. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  387. ctx.So(err, convey.ShouldBeNil)
  388. ctx.So(res, convey.ShouldNotBeNil)
  389. })
  390. })
  391. })
  392. }
  393. func TestNewcomerRewardActivate2(t *testing.T) {
  394. convey.Convey("RewardActivate2", t, func(ctx convey.C) {
  395. var (
  396. c = context.Background()
  397. mid = int64(27515308)
  398. oid = int64(2)
  399. nid = int64(1)
  400. )
  401. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  402. res, err := d.RewardActivate2(c, mid, oid, nid)
  403. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  404. ctx.So(err, convey.ShouldBeNil)
  405. ctx.So(res, convey.ShouldNotBeNil)
  406. })
  407. })
  408. })
  409. }