mc.cache_test.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/ugcpay-rank/internal/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoSetCacheElecUPRank(t *testing.T) {
  9. convey.Convey("SetCacheElecUPRank", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. id = int64(233)
  13. ver = int64(0)
  14. val = &model.RankElecUPProto{
  15. CountUPTotalElec: 233,
  16. }
  17. )
  18. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  19. err := d.SetCacheElecUPRank(c, id, ver, val)
  20. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestDaoCacheElecUPRank(t *testing.T) {
  27. convey.Convey("CacheElecUPRank", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. id = int64(233)
  31. ver = int64(0)
  32. )
  33. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  34. res, err := d.CacheElecUPRank(c, id, ver)
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(res, convey.ShouldNotBeNil)
  37. res, err = d.CacheElecUPRank(c, 0, ver)
  38. ctx.So(err, convey.ShouldBeNil)
  39. ctx.So(res, convey.ShouldBeNil)
  40. })
  41. })
  42. }
  43. func TestDaoDelCacheElecUPRank(t *testing.T) {
  44. convey.Convey("DelCacheElecUPRank", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. id = int64(233)
  48. ver = int64(0)
  49. )
  50. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  51. err := d.DelCacheElecUPRank(c, id, ver)
  52. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. })
  55. })
  56. })
  57. }
  58. func TestDaoSetCacheElecAVRank(t *testing.T) {
  59. convey.Convey("SetCacheElecAVRank", t, func(ctx convey.C) {
  60. var (
  61. c = context.Background()
  62. id = int64(233)
  63. val = &model.RankElecAVProto{
  64. CountUPTotalElec: 233,
  65. }
  66. ver = int64(0)
  67. )
  68. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  69. err := d.SetCacheElecAVRank(c, id, ver, val)
  70. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. })
  73. })
  74. })
  75. }
  76. func TestDaoCacheElecAVRank(t *testing.T) {
  77. convey.Convey("CacheElecAVRank", t, func(ctx convey.C) {
  78. var (
  79. c = context.Background()
  80. id = int64(233)
  81. ver = int64(0)
  82. )
  83. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  84. res, err := d.CacheElecAVRank(c, id, ver)
  85. ctx.So(err, convey.ShouldBeNil)
  86. ctx.So(res, convey.ShouldNotBeNil)
  87. res, err = d.CacheElecAVRank(c, 0, ver)
  88. ctx.So(err, convey.ShouldBeNil)
  89. ctx.So(res, convey.ShouldBeNil)
  90. })
  91. })
  92. }
  93. func TestDaoDelCacheElecAVRank(t *testing.T) {
  94. convey.Convey("DelCacheElecAVRank", t, func(ctx convey.C) {
  95. var (
  96. c = context.Background()
  97. id = int64(233)
  98. ver = int64(0)
  99. )
  100. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  101. err := d.DelCacheElecAVRank(c, id, ver)
  102. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  103. ctx.So(err, convey.ShouldBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDaoSetCacheElecPrepUPRank(t *testing.T) {
  109. convey.Convey("SetCacheElecPrepUPRank", t, func(ctx convey.C) {
  110. var (
  111. c = context.Background()
  112. id = int64(233)
  113. val = &model.RankElecPrepUPProto{
  114. Count: 233,
  115. }
  116. ver = int64(0)
  117. )
  118. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  119. err := d.SetCacheElecPrepUPRank(c, id, ver, val)
  120. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  121. ctx.So(err, convey.ShouldBeNil)
  122. })
  123. })
  124. })
  125. }
  126. func TestDaoCacheElecPrepUPRank(t *testing.T) {
  127. convey.Convey("CacheElecPrepUPRank", t, func(ctx convey.C) {
  128. var (
  129. c = context.Background()
  130. id = int64(233)
  131. ver = int64(0)
  132. )
  133. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  134. res, item, err := d.CacheElecPrepUPRank(c, id, ver)
  135. ctx.So(err, convey.ShouldBeNil)
  136. ctx.So(item, convey.ShouldNotBeNil)
  137. ctx.So(res, convey.ShouldNotBeNil)
  138. res, item, err = d.CacheElecPrepUPRank(c, 0, ver)
  139. ctx.So(err, convey.ShouldBeNil)
  140. ctx.So(item, convey.ShouldBeNil)
  141. ctx.So(res, convey.ShouldBeNil)
  142. })
  143. })
  144. }
  145. func TestDaoDelCacheElecPrepUPRank(t *testing.T) {
  146. convey.Convey("DelCacheElecPrepUPRank", t, func(ctx convey.C) {
  147. var (
  148. c = context.Background()
  149. id = int64(233)
  150. ver = int64(0)
  151. )
  152. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  153. err := d.DelCacheElecPrepUPRank(c, id, ver)
  154. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  155. ctx.So(err, convey.ShouldBeNil)
  156. })
  157. })
  158. })
  159. }
  160. func TestDaoSetCacheElecPrepAVRank(t *testing.T) {
  161. convey.Convey("SetCacheElecPrepAVRank", t, func(ctx convey.C) {
  162. var (
  163. c = context.Background()
  164. id = int64(233)
  165. val = &model.RankElecPrepAVProto{
  166. AVID: 233,
  167. }
  168. ver = int64(0)
  169. )
  170. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  171. err := d.SetCacheElecPrepAVRank(c, id, ver, val)
  172. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  173. ctx.So(err, convey.ShouldBeNil)
  174. })
  175. })
  176. })
  177. }
  178. func TestDaoCacheElecPrepAVRank(t *testing.T) {
  179. convey.Convey("CacheElecPrepAVRank", t, func(ctx convey.C) {
  180. var (
  181. c = context.Background()
  182. id = int64(233)
  183. ver = int64(0)
  184. )
  185. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  186. res, item, err := d.CacheElecPrepAVRank(c, id, ver)
  187. ctx.So(err, convey.ShouldBeNil)
  188. ctx.So(item, convey.ShouldNotBeNil)
  189. ctx.So(res, convey.ShouldNotBeNil)
  190. res, item, err = d.CacheElecPrepAVRank(c, 0, ver)
  191. ctx.So(err, convey.ShouldBeNil)
  192. ctx.So(item, convey.ShouldBeNil)
  193. ctx.So(res, convey.ShouldBeNil)
  194. })
  195. })
  196. }
  197. func TestDaoDelCacheElecPrepAVRank(t *testing.T) {
  198. convey.Convey("DelCacheElecPrepAVRank", t, func(ctx convey.C) {
  199. var (
  200. c = context.Background()
  201. id = int64(233)
  202. ver = int64(0)
  203. )
  204. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  205. err := d.DelCacheElecPrepAVRank(c, id, ver)
  206. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  207. ctx.So(err, convey.ShouldBeNil)
  208. })
  209. })
  210. })
  211. }
  212. func TestDaoAddCacheElecPrepAVRank(t *testing.T) {
  213. convey.Convey("AddCacheElecPrepAVRank", t, func(ctx convey.C) {
  214. var (
  215. c = context.Background()
  216. id = int64(233)
  217. val = &model.RankElecPrepAVProto{
  218. AVID: 233,
  219. }
  220. ver = int64(0)
  221. )
  222. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  223. ok, err := d.AddCacheElecPrepAVRank(c, id, ver, val)
  224. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  225. ctx.So(err, convey.ShouldBeNil)
  226. ctx.So(ok, convey.ShouldNotBeNil)
  227. })
  228. })
  229. })
  230. }
  231. func TestDaoAddCacheElecPrepUPRank(t *testing.T) {
  232. convey.Convey("AddCacheElecPrepUPRank", t, func(ctx convey.C) {
  233. var (
  234. c = context.Background()
  235. id = int64(233)
  236. val = &model.RankElecPrepUPProto{
  237. UPMID: 233,
  238. }
  239. ver = int64(0)
  240. )
  241. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  242. ok, err := d.AddCacheElecPrepUPRank(c, id, ver, val)
  243. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  244. ctx.So(err, convey.ShouldBeNil)
  245. ctx.So(ok, convey.ShouldNotBeNil)
  246. })
  247. })
  248. })
  249. }