memcache_test.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/favorite/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestGETANDSetUserRecentResourcesMc(t *testing.T) {
  9. var (
  10. mid = int64(76)
  11. typ = int8(2)
  12. c = context.Background()
  13. )
  14. convey.Convey("folderMcKey", t, func(ctx convey.C) {
  15. recents, err := d.UserRecentResourcesMc(c, typ, mid)
  16. ctx.So(err, convey.ShouldBeNil)
  17. err = d.SetUserRecentResourcesMc(c, typ, mid, recents)
  18. ctx.So(err, convey.ShouldBeNil)
  19. err = d.DelRecentResMc(c, typ, mid)
  20. ctx.So(err, convey.ShouldBeNil)
  21. })
  22. }
  23. func TestFavfolderMcKey(t *testing.T) {
  24. var (
  25. mid = int64(0)
  26. fid = int64(0)
  27. )
  28. convey.Convey("folderMcKey", t, func(ctx convey.C) {
  29. p1 := folderMcKey(mid, fid)
  30. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  31. ctx.So(p1, convey.ShouldNotBeNil)
  32. })
  33. })
  34. }
  35. func TestFavfsortMcKey(t *testing.T) {
  36. var (
  37. typ = int8(0)
  38. mid = int64(0)
  39. )
  40. convey.Convey("fsortMcKey", t, func(ctx convey.C) {
  41. p1 := fsortMcKey(typ, mid)
  42. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  43. ctx.So(p1, convey.ShouldNotBeNil)
  44. })
  45. })
  46. }
  47. func TestFavrelationFidsKey(t *testing.T) {
  48. var (
  49. typ = int8(0)
  50. mid = int64(0)
  51. oid = int64(0)
  52. )
  53. convey.Convey("relationFidsKey", t, func(ctx convey.C) {
  54. p1 := relationFidsKey(typ, mid, oid)
  55. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  56. ctx.So(p1, convey.ShouldNotBeNil)
  57. })
  58. })
  59. }
  60. func TestFavoidCountKey(t *testing.T) {
  61. var (
  62. typ = int8(0)
  63. oid = int64(0)
  64. )
  65. convey.Convey("oidCountKey", t, func(ctx convey.C) {
  66. p1 := oidCountKey(typ, oid)
  67. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  68. ctx.So(p1, convey.ShouldNotBeNil)
  69. })
  70. })
  71. }
  72. func TestFavbatchOidsKey(t *testing.T) {
  73. var (
  74. typ = int8(0)
  75. mid = int64(0)
  76. )
  77. convey.Convey("batchOidsKey", t, func(ctx convey.C) {
  78. p1 := batchOidsKey(typ, mid)
  79. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  80. ctx.So(p1, convey.ShouldNotBeNil)
  81. })
  82. })
  83. }
  84. func TestFavpingMC(t *testing.T) {
  85. var (
  86. c = context.TODO()
  87. )
  88. convey.Convey("pingMC", t, func(ctx convey.C) {
  89. err := d.pingMC(c)
  90. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  91. ctx.So(err, convey.ShouldBeNil)
  92. })
  93. })
  94. }
  95. func TestFavSetFoldersMc(t *testing.T) {
  96. var (
  97. c = context.TODO()
  98. vs = &model.Folder{}
  99. )
  100. convey.Convey("SetFoldersMc", t, func(ctx convey.C) {
  101. err := d.SetFoldersMc(c, vs)
  102. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  103. ctx.So(err, convey.ShouldBeNil)
  104. })
  105. })
  106. }
  107. func TestFavFoldersMc(t *testing.T) {
  108. var (
  109. c = context.TODO()
  110. fvmids = []*model.ArgFVmid{
  111. &model.ArgFVmid{
  112. Fid: 1,
  113. Vmid: 88888894,
  114. },
  115. }
  116. )
  117. convey.Convey("FoldersMc", t, func(ctx convey.C) {
  118. fs, missFvmids, err := d.FoldersMc(c, fvmids)
  119. ctx.Convey("Then err should be nil.fs,missFvmids should not be nil.", func(ctx convey.C) {
  120. ctx.So(err, convey.ShouldBeNil)
  121. ctx.So(missFvmids, convey.ShouldNotBeNil)
  122. ctx.So(fs, convey.ShouldNotBeNil)
  123. })
  124. })
  125. }
  126. func TestFavFolderMc(t *testing.T) {
  127. var (
  128. c = context.TODO()
  129. typ = int8(0)
  130. mid = int64(0)
  131. fid = int64(0)
  132. )
  133. convey.Convey("FolderMc", t, func(ctx convey.C) {
  134. f, err := d.FolderMc(c, typ, mid, fid)
  135. ctx.Convey("Then err should be nil.f should not be nil.", func(ctx convey.C) {
  136. ctx.So(err, convey.ShouldBeNil)
  137. ctx.So(f, convey.ShouldNotBeNil)
  138. })
  139. })
  140. }
  141. func TestFavDelFolderMc(t *testing.T) {
  142. var (
  143. c = context.TODO()
  144. typ = int8(0)
  145. mid = int64(0)
  146. fid = int64(0)
  147. )
  148. convey.Convey("DelFolderMc", t, func(ctx convey.C) {
  149. err := d.DelFolderMc(c, typ, mid, fid)
  150. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  151. ctx.So(err, convey.ShouldBeNil)
  152. })
  153. })
  154. }
  155. func TestFavSetFolderSortMc(t *testing.T) {
  156. var (
  157. c = context.TODO()
  158. fst = &model.FolderSort{}
  159. )
  160. convey.Convey("SetFolderSortMc", t, func(ctx convey.C) {
  161. err := d.SetFolderSortMc(c, fst)
  162. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  163. ctx.So(err, convey.ShouldBeNil)
  164. })
  165. })
  166. }
  167. func TestFavFolderSortMc(t *testing.T) {
  168. var (
  169. c = context.TODO()
  170. typ = int8(0)
  171. mid = int64(0)
  172. )
  173. convey.Convey("FolderSortMc", t, func(ctx convey.C) {
  174. fst, err := d.FolderSortMc(c, typ, mid)
  175. ctx.Convey("Then err should be nil.fst should not be nil.", func(ctx convey.C) {
  176. ctx.So(err, convey.ShouldBeNil)
  177. ctx.So(fst, convey.ShouldNotBeNil)
  178. })
  179. })
  180. }
  181. func TestFavDelFolderSortMc(t *testing.T) {
  182. var (
  183. c = context.TODO()
  184. typ = int8(0)
  185. mid = int64(0)
  186. )
  187. convey.Convey("DelFolderSortMc", t, func(ctx convey.C) {
  188. err := d.DelFolderSortMc(c, typ, mid)
  189. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  190. ctx.So(err, convey.ShouldBeNil)
  191. })
  192. })
  193. }
  194. func TestFavSetRelaitonFidsMc(t *testing.T) {
  195. var (
  196. c = context.TODO()
  197. typ = int8(1)
  198. mid = int64(88888894)
  199. oid = int64(1)
  200. fids = []int64{1}
  201. )
  202. convey.Convey("SetRelaitonFidsMc", t, func(ctx convey.C) {
  203. err := d.SetRelaitonFidsMc(c, typ, mid, oid, fids)
  204. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  205. ctx.So(err, convey.ShouldBeNil)
  206. })
  207. })
  208. }
  209. func TestFavRelaitonFidsMc(t *testing.T) {
  210. var (
  211. c = context.TODO()
  212. typ = int8(1)
  213. mid = int64(88888894)
  214. oid = int64(1)
  215. )
  216. convey.Convey("RelaitonFidsMc", t, func(ctx convey.C) {
  217. fids, err := d.RelaitonFidsMc(c, typ, mid, oid)
  218. ctx.Convey("Then err should be nil.fids should not be nil.", func(ctx convey.C) {
  219. ctx.So(err, convey.ShouldBeNil)
  220. ctx.So(fids, convey.ShouldNotBeNil)
  221. })
  222. })
  223. }
  224. func TestFavDelRelationFidsMc(t *testing.T) {
  225. var (
  226. c = context.TODO()
  227. typ = int8(0)
  228. mid = int64(0)
  229. oids = int64(0)
  230. )
  231. convey.Convey("DelRelationFidsMc", t, func(ctx convey.C) {
  232. err := d.DelRelationFidsMc(c, typ, mid, oids)
  233. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  234. ctx.So(err, convey.ShouldBeNil)
  235. })
  236. })
  237. }
  238. func TestFavSetOidCountMc(t *testing.T) {
  239. var (
  240. c = context.TODO()
  241. typ = int8(0)
  242. oid = int64(0)
  243. count = int64(0)
  244. )
  245. convey.Convey("SetOidCountMc", t, func(ctx convey.C) {
  246. err := d.SetOidCountMc(c, typ, oid, count)
  247. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  248. ctx.So(err, convey.ShouldBeNil)
  249. })
  250. })
  251. }
  252. func TestFavOidCountMc(t *testing.T) {
  253. var (
  254. c = context.TODO()
  255. typ = int8(0)
  256. oid = int64(0)
  257. )
  258. convey.Convey("OidCountMc", t, func(ctx convey.C) {
  259. count, err := d.OidCountMc(c, typ, oid)
  260. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  261. ctx.So(err, convey.ShouldBeNil)
  262. ctx.So(count, convey.ShouldNotBeNil)
  263. })
  264. })
  265. }
  266. func TestFavOidsCountMc(t *testing.T) {
  267. var (
  268. c = context.TODO()
  269. typ = int8(1)
  270. oids = []int64{1, 2, 3}
  271. )
  272. convey.Convey("OidsCountMc", t, func(ctx convey.C) {
  273. counts, misOids, err := d.OidsCountMc(c, typ, oids)
  274. ctx.Convey("Then err should be nil.counts,misOids should not be nil.", func(ctx convey.C) {
  275. ctx.So(err, convey.ShouldBeNil)
  276. ctx.So(misOids, convey.ShouldNotBeNil)
  277. ctx.So(counts, convey.ShouldNotBeNil)
  278. })
  279. })
  280. }
  281. func TestFavSetOidsCountMc(t *testing.T) {
  282. var (
  283. c = context.TODO()
  284. typ = int8(0)
  285. cnts map[int64]int64
  286. )
  287. convey.Convey("SetOidsCountMc", t, func(ctx convey.C) {
  288. err := d.SetOidsCountMc(c, typ, cnts)
  289. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  290. ctx.So(err, convey.ShouldBeNil)
  291. })
  292. })
  293. }
  294. func TestFavBatchOidsMc(t *testing.T) {
  295. var (
  296. c = context.TODO()
  297. typ = int8(1)
  298. mid = int64(88888894)
  299. )
  300. convey.Convey("BatchOidsMc", t, func(ctx convey.C) {
  301. _, err := d.BatchOidsMc(c, typ, mid)
  302. ctx.Convey("Then err should be nil.oids should not be nil.", func(ctx convey.C) {
  303. ctx.So(err, convey.ShouldBeNil)
  304. })
  305. })
  306. }
  307. func TestFavSetBatchOidsMc(t *testing.T) {
  308. var (
  309. c = context.TODO()
  310. typ = int8(1)
  311. mid = int64(88888894)
  312. oids = []int64{1, 2, 3}
  313. )
  314. convey.Convey("SetBatchOidsMc", t, func(ctx convey.C) {
  315. err := d.SetBatchOidsMc(c, typ, mid, oids)
  316. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  317. ctx.So(err, convey.ShouldBeNil)
  318. })
  319. })
  320. }