memcache_test.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. package medal
  2. import (
  3. "go-common/app/service/main/usersuit/model"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestMedalactivatedNidKey(t *testing.T) {
  8. convey.Convey("activatedNidKey", t, func(ctx convey.C) {
  9. var (
  10. mid = int64(88889017)
  11. )
  12. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  13. p1 := activatedNidKey(mid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestMedalownersKey(t *testing.T) {
  21. convey.Convey("ownersKey", t, func(ctx convey.C) {
  22. var (
  23. mid = int64(88889017)
  24. )
  25. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  26. p1 := ownersKey(mid)
  27. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  28. ctx.So(p1, convey.ShouldNotBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestMedalRedPointKey(t *testing.T) {
  34. convey.Convey("RedPointKey", t, func(ctx convey.C) {
  35. var (
  36. mid = int64(88889017)
  37. )
  38. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  39. p1 := RedPointKey(mid)
  40. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  41. ctx.So(p1, convey.ShouldNotBeNil)
  42. })
  43. })
  44. })
  45. }
  46. func TestMedalPopupKey(t *testing.T) {
  47. convey.Convey("PopupKey", t, func(ctx convey.C) {
  48. var (
  49. mid = int64(88889017)
  50. )
  51. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  52. p1 := PopupKey(mid)
  53. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  54. ctx.So(p1, convey.ShouldNotBeNil)
  55. })
  56. })
  57. })
  58. }
  59. func TestMedalpingMC(t *testing.T) {
  60. convey.Convey("pingMC", t, func(ctx convey.C) {
  61. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  62. err := d.pingMC(c)
  63. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestMedalSetMedalOwnersache(t *testing.T) {
  70. convey.Convey("SetMedalOwnersache", t, func(ctx convey.C) {
  71. var (
  72. mid = int64(88889017)
  73. nos = []*model.MedalOwner{}
  74. )
  75. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  76. err := d.SetMedalOwnersache(c, mid, nos)
  77. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. })
  80. })
  81. })
  82. }
  83. func TestMedalMedalOwnersCache(t *testing.T) {
  84. convey.Convey("MedalOwnersCache", t, func(ctx convey.C) {
  85. var (
  86. mid = int64(88889017)
  87. nos = []*model.MedalOwner{}
  88. )
  89. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  90. d.SetMedalOwnersache(c, mid, nos)
  91. res, notFound, err := d.MedalOwnersCache(c, mid)
  92. ctx.Convey("Then err should be nil.res,notFound should not be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(notFound, convey.ShouldNotBeNil)
  95. ctx.So(res, convey.ShouldNotBeNil)
  96. })
  97. })
  98. })
  99. }
  100. func TestMedalDelMedalOwnersCache(t *testing.T) {
  101. convey.Convey("DelMedalOwnersCache", t, func(ctx convey.C) {
  102. var (
  103. mid = int64(88889017)
  104. )
  105. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  106. err := d.DelMedalOwnersCache(c, mid)
  107. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  108. ctx.So(err, convey.ShouldBeNil)
  109. })
  110. })
  111. })
  112. }
  113. func TestMedalmedalsActivatedCache(t *testing.T) {
  114. convey.Convey("medalsActivatedCache", t, func(ctx convey.C) {
  115. var (
  116. mids = []int64{88889017}
  117. )
  118. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  119. nids, missed, err := d.medalsActivatedCache(c, mids)
  120. ctx.Convey("Then err should be nil.nids,missed should not be nil.", func(ctx convey.C) {
  121. ctx.So(err, convey.ShouldBeNil)
  122. ctx.So(missed, convey.ShouldNotBeNil)
  123. ctx.So(nids, convey.ShouldNotBeNil)
  124. })
  125. })
  126. })
  127. }
  128. func TestMedalSetMedalActivatedCache(t *testing.T) {
  129. convey.Convey("SetMedalActivatedCache", t, func(ctx convey.C) {
  130. var (
  131. mid = int64(88889017)
  132. nid = int64(1)
  133. )
  134. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  135. err := d.SetMedalActivatedCache(c, mid, nid)
  136. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  137. ctx.So(err, convey.ShouldBeNil)
  138. })
  139. })
  140. })
  141. }
  142. func TestMedalmedalActivatedCache(t *testing.T) {
  143. convey.Convey("medalActivatedCache", t, func(ctx convey.C) {
  144. var (
  145. mid = int64(88889017)
  146. )
  147. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  148. nid, notFound, err := d.medalActivatedCache(c, mid)
  149. ctx.Convey("Then err should be nil.nid,notFound should not be nil.", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldBeNil)
  151. ctx.So(notFound, convey.ShouldNotBeNil)
  152. ctx.So(nid, convey.ShouldNotBeNil)
  153. })
  154. })
  155. })
  156. }
  157. func TestMedalDelMedalActivatedCache(t *testing.T) {
  158. convey.Convey("DelMedalActivatedCache", t, func(ctx convey.C) {
  159. var (
  160. mid = int64(88889017)
  161. )
  162. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  163. err := d.DelMedalActivatedCache(c, mid)
  164. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  165. ctx.So(err, convey.ShouldBeNil)
  166. })
  167. })
  168. })
  169. }
  170. func TestMedalPopupCache(t *testing.T) {
  171. convey.Convey("PopupCache", t, func(ctx convey.C) {
  172. var (
  173. mid = int64(88889017)
  174. )
  175. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  176. nid, err := d.PopupCache(c, mid)
  177. ctx.Convey("Then err should be nil.nid should not be nil.", func(ctx convey.C) {
  178. ctx.So(err, convey.ShouldBeNil)
  179. ctx.So(nid, convey.ShouldNotBeNil)
  180. })
  181. })
  182. })
  183. }
  184. func TestMedalSetPopupCache(t *testing.T) {
  185. convey.Convey("SetPopupCache", t, func(ctx convey.C) {
  186. var (
  187. mid = int64(88889017)
  188. nid = int64(1)
  189. )
  190. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  191. err := d.SetPopupCache(c, mid, nid)
  192. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  193. ctx.So(err, convey.ShouldBeNil)
  194. })
  195. })
  196. })
  197. }
  198. func TestMedalDelPopupCache(t *testing.T) {
  199. convey.Convey("DelPopupCache", t, func(ctx convey.C) {
  200. var (
  201. mid = int64(88889017)
  202. )
  203. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  204. err := d.DelPopupCache(c, mid)
  205. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  206. ctx.So(err, convey.ShouldBeNil)
  207. })
  208. })
  209. })
  210. }
  211. func TestMedalRedPointCache(t *testing.T) {
  212. convey.Convey("RedPointCache", t, func(ctx convey.C) {
  213. var (
  214. mid = int64(88889017)
  215. )
  216. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  217. nid, err := d.RedPointCache(c, mid)
  218. ctx.Convey("Then err should be nil.nid should not be nil.", func(ctx convey.C) {
  219. ctx.So(err, convey.ShouldBeNil)
  220. ctx.So(nid, convey.ShouldNotBeNil)
  221. })
  222. })
  223. })
  224. }
  225. func TestMedalSetRedPointCache(t *testing.T) {
  226. convey.Convey("SetRedPointCache", t, func(ctx convey.C) {
  227. var (
  228. mid = int64(88889017)
  229. nid = int64(1)
  230. )
  231. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  232. err := d.SetRedPointCache(c, mid, nid)
  233. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  234. ctx.So(err, convey.ShouldBeNil)
  235. })
  236. })
  237. })
  238. }
  239. func TestMedalDelRedPointCache(t *testing.T) {
  240. convey.Convey("DelRedPointCache", t, func(ctx convey.C) {
  241. var (
  242. mid = int64(88889017)
  243. )
  244. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  245. err := d.DelRedPointCache(c, mid)
  246. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  247. ctx.So(err, convey.ShouldBeNil)
  248. })
  249. })
  250. })
  251. }