vip_test.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/vip/model"
  5. xtime "go-common/library/time"
  6. "testing"
  7. "time"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoAddChangeHistoryBatch(t *testing.T) {
  11. convey.Convey("AddChangeHistoryBatch", t, func(ctx convey.C) {
  12. var (
  13. res = []*model.VipChangeHistory{}
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. err := d.AddChangeHistoryBatch(res)
  17. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoSelChangeHistory(t *testing.T) {
  24. convey.Convey("SelChangeHistory", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. startID = int64(0)
  28. endID = int64(0)
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. _, err := d.SelChangeHistory(c, startID, endID)
  32. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoSelOldChangeHistory(t *testing.T) {
  39. convey.Convey("SelOldChangeHistory", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. startID = int64(0)
  43. endID = int64(0)
  44. )
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. _, err := d.SelOldChangeHistory(c, startID, endID)
  47. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestDaoSelOldChangeHistoryMaxID(t *testing.T) {
  54. convey.Convey("SelOldChangeHistoryMaxID", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. _, err := d.SelOldChangeHistoryMaxID(c)
  60. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaoSelChangeHistoryMaxID(t *testing.T) {
  67. convey.Convey("SelChangeHistoryMaxID", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. )
  71. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  72. _, err := d.SelChangeHistoryMaxID(c)
  73. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  74. ctx.So(err, convey.ShouldBeNil)
  75. })
  76. })
  77. })
  78. }
  79. func TestDaoVipStatus(t *testing.T) {
  80. convey.Convey("VipStatus", t, func(ctx convey.C) {
  81. var (
  82. c = context.Background()
  83. mid = int64(0)
  84. )
  85. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  86. _, err := d.VipStatus(c, mid)
  87. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. })
  92. }
  93. func TestDaoSelMaxID(t *testing.T) {
  94. convey.Convey("SelMaxID", t, func(ctx convey.C) {
  95. var (
  96. c = context.Background()
  97. )
  98. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  99. _, err := d.SelMaxID(c)
  100. ctx.Convey("Then err should be nil.mID should not be nil.", func(ctx convey.C) {
  101. ctx.So(err, convey.ShouldBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestDaoUpdateVipUserInfo(t *testing.T) {
  107. convey.Convey("UpdateVipUserInfo", t, func(ctx convey.C) {
  108. var (
  109. r = &model.VipUserInfo{}
  110. )
  111. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  112. tx, err := d.StartTx(context.Background())
  113. ctx.So(err, convey.ShouldBeNil)
  114. ctx.So(tx, convey.ShouldNotBeNil)
  115. _, err = d.UpdateVipUserInfo(tx, r)
  116. ctx.Convey("Then err should be nil.a should not be nil.", func(ctx convey.C) {
  117. ctx.So(err, convey.ShouldBeNil)
  118. })
  119. })
  120. })
  121. }
  122. func TestDaoUpdateVipUser(t *testing.T) {
  123. convey.Convey("UpdateVipUser", t, func(ctx convey.C) {
  124. var (
  125. c = context.Background()
  126. mid = int64(0)
  127. status = int8(0)
  128. vipType = int8(0)
  129. payType = int8(0)
  130. )
  131. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  132. _, err := d.UpdateVipUser(c, mid, status, vipType, payType)
  133. ctx.Convey("Then err should be nil.eff should not be nil.", func(ctx convey.C) {
  134. ctx.So(err, convey.ShouldBeNil)
  135. })
  136. })
  137. })
  138. }
  139. func TestDaoDupUserDiscountHistory(t *testing.T) {
  140. convey.Convey("DupUserDiscountHistory", t, func(ctx convey.C) {
  141. var (
  142. r = &model.VipUserDiscountHistory{}
  143. )
  144. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  145. tx, err := d.StartTx(context.Background())
  146. ctx.So(err, convey.ShouldBeNil)
  147. ctx.So(tx, convey.ShouldNotBeNil)
  148. _, err = d.DupUserDiscountHistory(tx, r)
  149. ctx.Convey("Then err should be nil.a should not be nil.", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldBeNil)
  151. })
  152. })
  153. })
  154. }
  155. func TestDaoAddUserInfo(t *testing.T) {
  156. convey.Convey("AddUserInfo", t, func(ctx convey.C) {
  157. var (
  158. r = &model.VipUserInfo{}
  159. )
  160. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  161. tx, err := d.StartTx(context.Background())
  162. ctx.So(err, convey.ShouldBeNil)
  163. ctx.So(tx, convey.ShouldNotBeNil)
  164. _, err = d.AddUserInfo(tx, r)
  165. ctx.Convey("Then err should be nil.eff should not be nil.", func(ctx convey.C) {
  166. ctx.So(err, convey.ShouldBeNil)
  167. })
  168. })
  169. })
  170. }
  171. func TestDaoSelVipUserInfo(t *testing.T) {
  172. convey.Convey("SelVipUserInfo", t, func(ctx convey.C) {
  173. var (
  174. c = context.Background()
  175. mid = int64(0)
  176. )
  177. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  178. _, err := d.SelVipUserInfo(c, mid)
  179. ctx.Convey("Then err should be nil.r should not be nil.", func(ctx convey.C) {
  180. ctx.So(err, convey.ShouldBeNil)
  181. })
  182. })
  183. })
  184. }
  185. func TestDaoUpdateUserInfo(t *testing.T) {
  186. convey.Convey("UpdateUserInfo", t, func(ctx convey.C) {
  187. var (
  188. r = &model.VipUserInfo{}
  189. )
  190. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  191. tx, err := d.StartTx(context.Background())
  192. ctx.So(err, convey.ShouldBeNil)
  193. ctx.So(tx, convey.ShouldNotBeNil)
  194. _, err = d.UpdateUserInfo(tx, r)
  195. ctx.Convey("Then err should be nil.eff should not be nil.", func(ctx convey.C) {
  196. ctx.So(err, convey.ShouldBeNil)
  197. })
  198. })
  199. })
  200. }
  201. func TestDaoSelUserDiscountMaxID(t *testing.T) {
  202. convey.Convey("SelUserDiscountMaxID", t, func(ctx convey.C) {
  203. var (
  204. c = context.Background()
  205. )
  206. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  207. _, err := d.SelUserDiscountMaxID(c)
  208. ctx.Convey("Then err should be nil.maxID should not be nil.", func(ctx convey.C) {
  209. ctx.So(err, convey.ShouldBeNil)
  210. })
  211. })
  212. })
  213. }
  214. func TestDaoSelUserDiscountHistorys(t *testing.T) {
  215. convey.Convey("SelUserDiscountHistorys", t, func(ctx convey.C) {
  216. var (
  217. c = context.Background()
  218. sID = int(0)
  219. eID = int(0)
  220. discountID = int(0)
  221. )
  222. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  223. _, err := d.SelUserDiscountHistorys(c, sID, eID, discountID)
  224. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  225. ctx.So(err, convey.ShouldBeNil)
  226. })
  227. })
  228. })
  229. }
  230. func TestDaoSelOldUserInfoMaxID(t *testing.T) {
  231. convey.Convey("SelOldUserInfoMaxID", t, func(ctx convey.C) {
  232. var (
  233. c = context.Background()
  234. )
  235. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  236. _, err := d.SelOldUserInfoMaxID(c)
  237. ctx.Convey("Then err should be nil.maxID should not be nil.", func(ctx convey.C) {
  238. ctx.So(err, convey.ShouldBeNil)
  239. })
  240. })
  241. })
  242. }
  243. func TestDaoSelUserInfoMaxID(t *testing.T) {
  244. convey.Convey("SelUserInfoMaxID", t, func(ctx convey.C) {
  245. var (
  246. c = context.Background()
  247. )
  248. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  249. _, err := d.SelUserInfoMaxID(c)
  250. ctx.Convey("Then err should be nil.maxID should not be nil.", func(ctx convey.C) {
  251. ctx.So(err, convey.ShouldBeNil)
  252. })
  253. })
  254. })
  255. }
  256. func TestDaoSelUserInfos(t *testing.T) {
  257. convey.Convey("SelUserInfos", t, func(ctx convey.C) {
  258. var (
  259. c = context.Background()
  260. sID = int(0)
  261. eID = int(0)
  262. )
  263. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  264. _, err := d.SelUserInfos(c, sID, eID)
  265. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  266. ctx.So(err, convey.ShouldBeNil)
  267. })
  268. })
  269. })
  270. }
  271. func TestDaoSelVipList(t *testing.T) {
  272. convey.Convey("SelVipList", t, func(ctx convey.C) {
  273. var (
  274. c = context.Background()
  275. id = int(0)
  276. endID = int(0)
  277. ot = ""
  278. )
  279. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  280. _, err := d.SelVipList(c, id, endID, ot)
  281. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  282. ctx.So(err, convey.ShouldBeNil)
  283. })
  284. })
  285. })
  286. }
  287. func TestDaoSelVipUsers(t *testing.T) {
  288. convey.Convey("SelVipUsers", t, func(ctx convey.C) {
  289. var (
  290. c = context.Background()
  291. id = int(0)
  292. endID = int(0)
  293. )
  294. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  295. _, err := d.SelVipUsers(c, id, endID, xtime.Time(time.Now().Unix()), xtime.Time(time.Now().Unix()))
  296. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  297. ctx.So(err, convey.ShouldBeNil)
  298. })
  299. })
  300. })
  301. }
  302. func TestDaoSelVipUserInfos(t *testing.T) {
  303. convey.Convey("SelVipUserInfos", t, func(ctx convey.C) {
  304. var (
  305. c = context.Background()
  306. id = int(0)
  307. endID = int(0)
  308. status = int(0)
  309. )
  310. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  311. _, err := d.SelVipUserInfos(c, id, endID, xtime.Time(time.Now().Unix()), xtime.Time(time.Now().Unix()), status)
  312. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  313. ctx.So(err, convey.ShouldBeNil)
  314. })
  315. })
  316. })
  317. }
  318. func TestDaoOldVipInfo(t *testing.T) {
  319. convey.Convey("OldVipInfo", t, func(ctx convey.C) {
  320. var (
  321. c = context.Background()
  322. mid = int64(0)
  323. )
  324. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  325. _, err := d.OldVipInfo(c, mid)
  326. ctx.Convey("Then err should be nil.r should not be nil.", func(ctx convey.C) {
  327. ctx.So(err, convey.ShouldBeNil)
  328. })
  329. })
  330. })
  331. }
  332. func TestDaoSelEffectiveScopeVipList(t *testing.T) {
  333. convey.Convey("SelEffectiveScopeVipList", t, func(ctx convey.C) {
  334. var (
  335. c = context.Background()
  336. id = int(0)
  337. endID = int(0)
  338. )
  339. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  340. _, err := d.SelEffectiveScopeVipList(c, id, endID)
  341. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  342. ctx.So(err, convey.ShouldBeNil)
  343. })
  344. })
  345. })
  346. }
  347. func TestDaoSelOldUserInfoMaps(t *testing.T) {
  348. convey.Convey("SelOldUserInfoMaps", t, func(ctx convey.C) {
  349. var (
  350. c = context.Background()
  351. sID = int(0)
  352. eID = int(0)
  353. )
  354. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  355. _, err := d.SelOldUserInfoMaps(c, sID, eID)
  356. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  357. ctx.So(err, convey.ShouldBeNil)
  358. })
  359. })
  360. })
  361. }
  362. func Test_SelChangeHistoryMaps(t *testing.T) {
  363. convey.Convey("SelChangeHistoryMaps", t, func(ctx convey.C) {
  364. _, err := d.SelChangeHistoryMaps(context.Background(), []int64{7593623})
  365. ctx.So(err, convey.ShouldBeNil)
  366. })
  367. }
  368. func Test_SelOldChangeHistoryMaps(t *testing.T) {
  369. convey.Convey("SelOldChangeHistoryMaps", t, func(ctx convey.C) {
  370. _, err := d.SelOldChangeHistoryMaps(context.Background(), []int64{7593623})
  371. ctx.So(err, convey.ShouldBeNil)
  372. })
  373. }
  374. func Test_SelVipByIds(t *testing.T) {
  375. convey.Convey("SelVipByIds", t, func(ctx convey.C) {
  376. _, err := d.SelVipByIds(context.Background(), []int64{7593623})
  377. ctx.So(err, convey.ShouldBeNil)
  378. })
  379. }