ranking_redis_test.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/web/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyRkList(t *testing.T) {
  9. convey.Convey("keyRkList", t, func(ctx convey.C) {
  10. var (
  11. rid = int16(1)
  12. rankType = int(0)
  13. day = int(1)
  14. arcType = int(0)
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. p1 := keyRkList(rid, rankType, day, arcType)
  18. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  19. ctx.So(p1, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaokeyRkListBak(t *testing.T) {
  25. convey.Convey("keyRkListBak", t, func(ctx convey.C) {
  26. var (
  27. rid = int16(0)
  28. rankType = int(0)
  29. day = int(0)
  30. arcType = int(0)
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. p1 := keyRkListBak(rid, rankType, day, arcType)
  34. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  35. ctx.So(p1, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaokeyRkIndex(t *testing.T) {
  41. convey.Convey("keyRkIndex", t, func(ctx convey.C) {
  42. var (
  43. day = int(1)
  44. )
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. p1 := keyRkIndex(day)
  47. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  48. ctx.So(p1, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestDaokeyRkIndexBak(t *testing.T) {
  54. convey.Convey("keyRkIndexBak", t, func(ctx convey.C) {
  55. var (
  56. day = int(1)
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. p1 := keyRkIndexBak(day)
  60. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  61. ctx.So(p1, convey.ShouldNotBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaokeyRkRegionList(t *testing.T) {
  67. convey.Convey("keyRkRegionList", t, func(ctx convey.C) {
  68. var (
  69. rid = int16(1)
  70. day = int(3)
  71. original = int(0)
  72. )
  73. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  74. p1 := keyRkRegionList(rid, day, original)
  75. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  76. ctx.So(p1, convey.ShouldNotBeNil)
  77. })
  78. })
  79. })
  80. }
  81. func TestDaokeyRkRegionListBak(t *testing.T) {
  82. convey.Convey("keyRkRegionListBak", t, func(ctx convey.C) {
  83. var (
  84. rid = int16(1)
  85. day = int(3)
  86. original = int(0)
  87. )
  88. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  89. p1 := keyRkRegionListBak(rid, day, original)
  90. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  91. ctx.So(p1, convey.ShouldNotBeNil)
  92. })
  93. })
  94. })
  95. }
  96. func TestDaokeyRkRecommendList(t *testing.T) {
  97. convey.Convey("keyRkRecommendList", t, func(ctx convey.C) {
  98. var (
  99. rid = int16(1)
  100. )
  101. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  102. p1 := keyRkRecommendList(rid)
  103. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  104. ctx.So(p1, convey.ShouldNotBeNil)
  105. })
  106. })
  107. })
  108. }
  109. func TestDaokeyRkRecommendListBak(t *testing.T) {
  110. convey.Convey("keyRkRecommendListBak", t, func(ctx convey.C) {
  111. var (
  112. rid = int16(1)
  113. )
  114. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  115. p1 := keyRkRecommendListBak(rid)
  116. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  117. ctx.So(p1, convey.ShouldNotBeNil)
  118. })
  119. })
  120. })
  121. }
  122. func TestDaokeyRkTagList(t *testing.T) {
  123. convey.Convey("keyRkTagList", t, func(ctx convey.C) {
  124. var (
  125. rid = int16(1)
  126. tagID = int64(1)
  127. )
  128. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  129. p1 := keyRkTagList(rid, tagID)
  130. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  131. ctx.So(p1, convey.ShouldNotBeNil)
  132. })
  133. })
  134. })
  135. }
  136. func TestDaokeyRkTagListBak(t *testing.T) {
  137. convey.Convey("keyRkTagListBak", t, func(ctx convey.C) {
  138. var (
  139. rid = int16(1)
  140. tagID = int64(1)
  141. )
  142. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  143. p1 := keyRkTagListBak(rid, tagID)
  144. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  145. ctx.So(p1, convey.ShouldNotBeNil)
  146. })
  147. })
  148. })
  149. }
  150. func TestDaoRankingCache(t *testing.T) {
  151. convey.Convey("RankingCache", t, func(ctx convey.C) {
  152. var (
  153. c = context.Background()
  154. rid = int16(1)
  155. rankType = int(1)
  156. day = int(3)
  157. arcType = int(1)
  158. )
  159. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  160. data, err := d.RankingCache(c, rid, rankType, day, arcType)
  161. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  162. ctx.So(err, convey.ShouldBeNil)
  163. ctx.Printf("%+v", data)
  164. })
  165. })
  166. })
  167. }
  168. func TestDaoRankingBakCache(t *testing.T) {
  169. convey.Convey("RankingBakCache", t, func(ctx convey.C) {
  170. var (
  171. c = context.Background()
  172. rid = int16(1)
  173. rankType = int(1)
  174. day = int(3)
  175. arcType = int(1)
  176. )
  177. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  178. data, err := d.RankingBakCache(c, rid, rankType, day, arcType)
  179. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  180. ctx.So(err, convey.ShouldBeNil)
  181. ctx.Printf("%+v", data)
  182. })
  183. })
  184. })
  185. }
  186. func TestDaoRankingIndexCache(t *testing.T) {
  187. convey.Convey("RankingIndexCache", t, func(ctx convey.C) {
  188. var (
  189. c = context.Background()
  190. day = int(3)
  191. )
  192. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  193. arcs, err := d.RankingIndexCache(c, day)
  194. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  195. ctx.So(err, convey.ShouldBeNil)
  196. ctx.Printf("%+v", arcs)
  197. })
  198. })
  199. })
  200. }
  201. func TestDaoRankingIndexBakCache(t *testing.T) {
  202. convey.Convey("RankingIndexBakCache", t, func(ctx convey.C) {
  203. var (
  204. c = context.Background()
  205. day = int(3)
  206. )
  207. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  208. arcs, err := d.RankingIndexBakCache(c, day)
  209. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  210. ctx.So(err, convey.ShouldBeNil)
  211. ctx.Printf("%+v", arcs)
  212. })
  213. })
  214. })
  215. }
  216. func TestDaoRankingRegionCache(t *testing.T) {
  217. convey.Convey("RankingRegionCache", t, func(ctx convey.C) {
  218. var (
  219. c = context.Background()
  220. rid = int16(1)
  221. day = int(3)
  222. original = int(0)
  223. )
  224. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  225. arcs, err := d.RankingRegionCache(c, rid, day, original)
  226. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  227. ctx.So(err, convey.ShouldBeNil)
  228. ctx.Printf("%+v", arcs)
  229. })
  230. })
  231. })
  232. }
  233. func TestDaoRankingRegionBakCache(t *testing.T) {
  234. convey.Convey("RankingRegionBakCache", t, func(ctx convey.C) {
  235. var (
  236. c = context.Background()
  237. rid = int16(1)
  238. day = int(3)
  239. original = int(0)
  240. )
  241. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  242. arcs, err := d.RankingRegionBakCache(c, rid, day, original)
  243. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  244. ctx.So(err, convey.ShouldBeNil)
  245. ctx.Printf("%+v", arcs)
  246. })
  247. })
  248. })
  249. }
  250. func TestDaoRankingRecommendCache(t *testing.T) {
  251. convey.Convey("RankingRecommendCache", t, func(ctx convey.C) {
  252. var (
  253. c = context.Background()
  254. rid = int16(1)
  255. )
  256. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  257. arcs, err := d.RankingRecommendCache(c, rid)
  258. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  259. ctx.So(err, convey.ShouldBeNil)
  260. ctx.Printf("%+v", arcs)
  261. })
  262. })
  263. })
  264. }
  265. func TestDaoRankingRecommendBakCache(t *testing.T) {
  266. convey.Convey("RankingRecommendBakCache", t, func(ctx convey.C) {
  267. var (
  268. c = context.Background()
  269. rid = int16(0)
  270. )
  271. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  272. arcs, err := d.RankingRecommendBakCache(c, rid)
  273. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  274. ctx.So(err, convey.ShouldBeNil)
  275. ctx.Printf("%+v", arcs)
  276. })
  277. })
  278. })
  279. }
  280. func TestDaoRankingTagCache(t *testing.T) {
  281. convey.Convey("RankingTagCache", t, func(ctx convey.C) {
  282. var (
  283. c = context.Background()
  284. rid = int16(0)
  285. tagID = int64(0)
  286. )
  287. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  288. arcs, err := d.RankingTagCache(c, rid, tagID)
  289. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  290. ctx.So(err, convey.ShouldBeNil)
  291. ctx.Printf("%+v", arcs)
  292. })
  293. })
  294. })
  295. }
  296. func TestDaoRankingTagBakCache(t *testing.T) {
  297. convey.Convey("RankingTagBakCache", t, func(ctx convey.C) {
  298. var (
  299. c = context.Background()
  300. rid = int16(0)
  301. tagID = int64(0)
  302. )
  303. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  304. arcs, err := d.RankingTagBakCache(c, rid, tagID)
  305. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  306. ctx.So(err, convey.ShouldBeNil)
  307. ctx.Printf("%+v", arcs)
  308. })
  309. })
  310. })
  311. }
  312. func TestDaoSetRegionCustomCache(t *testing.T) {
  313. convey.Convey("SetRegionCustomCache", t, func(ctx convey.C) {
  314. var (
  315. c = context.Background()
  316. data = []*model.Custom{{Aid: 1111}, {Aid: 2222}}
  317. )
  318. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  319. err := d.SetRegionCustomCache(c, data)
  320. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  321. ctx.So(err, convey.ShouldBeNil)
  322. })
  323. })
  324. })
  325. }
  326. func TestDaoRegionCustomCache(t *testing.T) {
  327. convey.Convey("RegionCustomCache", t, func(ctx convey.C) {
  328. var (
  329. c = context.Background()
  330. )
  331. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  332. res, err := d.RegionCustomCache(c)
  333. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  334. ctx.So(err, convey.ShouldBeNil)
  335. ctx.So(res, convey.ShouldNotBeNil)
  336. })
  337. })
  338. })
  339. }
  340. func TestDaoRegionCustomBakCache(t *testing.T) {
  341. convey.Convey("RegionCustomBakCache", t, func(ctx convey.C) {
  342. var (
  343. c = context.Background()
  344. )
  345. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  346. res, err := d.RegionCustomBakCache(c)
  347. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  348. ctx.So(err, convey.ShouldBeNil)
  349. ctx.So(res, convey.ShouldNotBeNil)
  350. })
  351. })
  352. })
  353. }
  354. func TestDaoSetRankingCache(t *testing.T) {
  355. convey.Convey("SetRankingCache", t, func(ctx convey.C) {
  356. var (
  357. c = context.Background()
  358. rid = int16(0)
  359. rankType = int(0)
  360. day = int(0)
  361. arcType = int(0)
  362. data = &model.RankData{}
  363. )
  364. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  365. err := d.SetRankingCache(c, rid, rankType, day, arcType, data)
  366. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  367. ctx.So(err, convey.ShouldBeNil)
  368. })
  369. })
  370. })
  371. }
  372. func TestDaoSetRankingIndexCache(t *testing.T) {
  373. convey.Convey("SetRankingIndexCache", t, func(ctx convey.C) {
  374. var (
  375. c = context.Background()
  376. day = int(0)
  377. arcs = []*model.IndexArchive{}
  378. )
  379. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  380. err := d.SetRankingIndexCache(c, day, arcs)
  381. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  382. ctx.So(err, convey.ShouldBeNil)
  383. })
  384. })
  385. })
  386. }
  387. func TestDaoSetRankingRegionCache(t *testing.T) {
  388. convey.Convey("SetRankingRegionCache", t, func(ctx convey.C) {
  389. var (
  390. c = context.Background()
  391. rid = int16(0)
  392. day = int(0)
  393. original = int(0)
  394. arcs = []*model.RegionArchive{}
  395. )
  396. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  397. err := d.SetRankingRegionCache(c, rid, day, original, arcs)
  398. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  399. ctx.So(err, convey.ShouldBeNil)
  400. })
  401. })
  402. })
  403. }
  404. func TestDaoSetRankingRecommendCache(t *testing.T) {
  405. convey.Convey("SetRankingRecommendCache", t, func(ctx convey.C) {
  406. var (
  407. c = context.Background()
  408. rid = int16(0)
  409. arcs = []*model.IndexArchive{}
  410. )
  411. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  412. err := d.SetRankingRecommendCache(c, rid, arcs)
  413. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  414. ctx.So(err, convey.ShouldBeNil)
  415. })
  416. })
  417. })
  418. }
  419. func TestDaoSetRankingTagCache(t *testing.T) {
  420. convey.Convey("SetRankingTagCache", t, func(ctx convey.C) {
  421. var (
  422. c = context.Background()
  423. rid = int16(0)
  424. tagID = int64(0)
  425. arcs = []*model.TagArchive{}
  426. )
  427. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  428. err := d.SetRankingTagCache(c, rid, tagID, arcs)
  429. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  430. ctx.So(err, convey.ShouldBeNil)
  431. })
  432. })
  433. })
  434. }