memcache_test.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. package fav
  2. import (
  3. "context"
  4. favmdl "go-common/app/service/main/favorite/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestFavfolderMcKey(t *testing.T) {
  9. convey.Convey("folderMcKey", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(0)
  12. fid = int64(0)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. p1 := folderMcKey(mid, fid)
  16. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  17. ctx.So(p1, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestFavrelationFidsKey(t *testing.T) {
  23. convey.Convey("relationFidsKey", t, func(ctx convey.C) {
  24. var (
  25. typ = int8(0)
  26. mid = int64(0)
  27. oid = int64(0)
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. p1 := relationFidsKey(typ, mid, oid)
  31. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  32. ctx.So(p1, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestFavoidCountKey(t *testing.T) {
  38. convey.Convey("oidCountKey", t, func(ctx convey.C) {
  39. var (
  40. typ = int8(0)
  41. oid = int64(0)
  42. )
  43. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  44. p1 := oidCountKey(typ, oid)
  45. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  46. ctx.So(p1, convey.ShouldNotBeNil)
  47. })
  48. })
  49. })
  50. }
  51. func TestFavbatchOidsKey(t *testing.T) {
  52. convey.Convey("batchOidsKey", t, func(ctx convey.C) {
  53. var (
  54. typ = int8(0)
  55. mid = int64(0)
  56. )
  57. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  58. p1 := batchOidsKey(typ, mid)
  59. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  60. ctx.So(p1, convey.ShouldNotBeNil)
  61. })
  62. })
  63. })
  64. }
  65. func TestFavrecentOidsKey(t *testing.T) {
  66. convey.Convey("recentOidsKey", t, func(ctx convey.C) {
  67. var (
  68. typ = int8(0)
  69. mid = int64(0)
  70. )
  71. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  72. p1 := recentOidsKey(typ, mid)
  73. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  74. ctx.So(p1, convey.ShouldNotBeNil)
  75. })
  76. })
  77. })
  78. }
  79. func TestFavPingMC(t *testing.T) {
  80. convey.Convey("PingMC", t, func(ctx convey.C) {
  81. var (
  82. c = context.Background()
  83. )
  84. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  85. err := d.pingMC(c)
  86. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  87. ctx.So(err, convey.ShouldBeNil)
  88. })
  89. })
  90. })
  91. }
  92. func TestFavSetFoldersMc(t *testing.T) {
  93. convey.Convey("SetFoldersMc", t, func(ctx convey.C) {
  94. var (
  95. c = context.Background()
  96. vs = &favmdl.Folder{}
  97. )
  98. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  99. err := d.SetFoldersMc(c, vs)
  100. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  101. ctx.So(err, convey.ShouldBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestFavFolderMc(t *testing.T) {
  107. convey.Convey("FolderMc", t, func(ctx convey.C) {
  108. var (
  109. c = context.Background()
  110. typ = int8(0)
  111. mid = int64(0)
  112. fid = int64(0)
  113. )
  114. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  115. f, err := d.FolderMc(c, typ, mid, fid)
  116. ctx.Convey("Then err should be nil.f should not be nil.", func(ctx convey.C) {
  117. ctx.So(err, convey.ShouldBeNil)
  118. ctx.So(f, convey.ShouldNotBeNil)
  119. })
  120. })
  121. })
  122. }
  123. func TestFavSetRelaitonFidsMc(t *testing.T) {
  124. convey.Convey("SetRelaitonFidsMc", t, func(ctx convey.C) {
  125. var (
  126. c = context.Background()
  127. typ = int8(0)
  128. mid = int64(0)
  129. oid = int64(0)
  130. fids = []int64{}
  131. )
  132. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  133. err := d.SetRelaitonFidsMc(c, typ, mid, oid, fids)
  134. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  135. ctx.So(err, convey.ShouldBeNil)
  136. })
  137. })
  138. })
  139. }
  140. func TestFavRelaitonFidsMc(t *testing.T) {
  141. convey.Convey("RelaitonFidsMc", t, func(ctx convey.C) {
  142. var (
  143. c = context.Background()
  144. typ = int8(0)
  145. mid = int64(0)
  146. oid = int64(0)
  147. )
  148. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  149. fids, err := d.RelaitonFidsMc(c, typ, mid, oid)
  150. ctx.Convey("Then err should be nil.fids should not be nil.", func(ctx convey.C) {
  151. ctx.So(err, convey.ShouldBeNil)
  152. ctx.So(fids, convey.ShouldNotBeNil)
  153. })
  154. })
  155. })
  156. }
  157. func TestFavDelRelationFidsMc(t *testing.T) {
  158. convey.Convey("DelRelationFidsMc", t, func(ctx convey.C) {
  159. var (
  160. c = context.Background()
  161. typ = int8(0)
  162. mid = int64(0)
  163. oid = int64(0)
  164. )
  165. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  166. err := d.DelRelationFidsMc(c, typ, mid, oid)
  167. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  168. ctx.So(err, convey.ShouldBeNil)
  169. })
  170. })
  171. })
  172. }
  173. func TestFavSetOidCountMc(t *testing.T) {
  174. convey.Convey("SetOidCountMc", t, func(ctx convey.C) {
  175. var (
  176. c = context.Background()
  177. typ = int8(0)
  178. oid = int64(0)
  179. count = int64(0)
  180. )
  181. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  182. err := d.SetOidCountMc(c, typ, oid, count)
  183. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  184. ctx.So(err, convey.ShouldBeNil)
  185. })
  186. })
  187. })
  188. }
  189. func TestFavDelBatchOidsMc(t *testing.T) {
  190. convey.Convey("DelBatchOidsMc", t, func(ctx convey.C) {
  191. var (
  192. c = context.Background()
  193. typ = int8(0)
  194. mid = int64(0)
  195. )
  196. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  197. err := d.DelBatchOidsMc(c, typ, mid)
  198. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  199. ctx.So(err, convey.ShouldBeNil)
  200. })
  201. })
  202. })
  203. }
  204. func TestFavDelRecentOidsMc(t *testing.T) {
  205. convey.Convey("DelRecentOidsMc", t, func(ctx convey.C) {
  206. var (
  207. c = context.Background()
  208. typ = int8(0)
  209. mid = int64(0)
  210. )
  211. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  212. err := d.DelRecentOidsMc(c, typ, mid)
  213. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  214. ctx.So(err, convey.ShouldBeNil)
  215. })
  216. })
  217. })
  218. }