channel_redis_test.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/space/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyCl(t *testing.T) {
  9. convey.Convey("keyCl", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(2222)
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. p1 := keyCl(mid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaokeyClArc(t *testing.T) {
  22. convey.Convey("keyClArc", t, func(ctx convey.C) {
  23. var (
  24. mid = int64(2222)
  25. cid = int64(2222)
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. p1 := keyClArc(mid, cid)
  29. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  30. ctx.So(p1, convey.ShouldNotBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaokeyClArcSort(t *testing.T) {
  36. convey.Convey("keyClArcSort", t, func(ctx convey.C) {
  37. var (
  38. mid = int64(2222)
  39. cid = int64(2222)
  40. )
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. p1 := keyClArcSort(mid, cid)
  43. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  44. ctx.So(p1, convey.ShouldNotBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoSetChannelListCache(t *testing.T) {
  50. convey.Convey("SetChannelListCache", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. mid = int64(2222)
  54. channelList = []*model.Channel{{Cid: 2222, Mid: 2222, Name: "2222"}, {Cid: 3333, Mid: 2222, Name: "3333"}}
  55. )
  56. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  57. err := d.SetChannelListCache(c, mid, channelList)
  58. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. })
  61. })
  62. })
  63. }
  64. func TestDaoSetChannelCache(t *testing.T) {
  65. convey.Convey("SetChannelCache", t, func(ctx convey.C) {
  66. var (
  67. c = context.Background()
  68. mid = int64(2222)
  69. cid = int64(2222)
  70. channel = &model.Channel{Cid: 2222, Mid: 2222}
  71. )
  72. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  73. err := d.SetChannelCache(c, mid, cid, channel)
  74. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. })
  77. })
  78. })
  79. }
  80. func TestDaoChannelCache(t *testing.T) {
  81. convey.Convey("ChannelCache", t, func(ctx convey.C) {
  82. var (
  83. c = context.Background()
  84. mid = int64(2222)
  85. cid = int64(2222)
  86. )
  87. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  88. channel, err := d.ChannelCache(c, mid, cid)
  89. ctx.Convey("Then err should be nil.channel should not be nil.", func(ctx convey.C) {
  90. ctx.So(err, convey.ShouldBeNil)
  91. ctx.So(channel, convey.ShouldNotBeNil)
  92. })
  93. })
  94. })
  95. }
  96. func TestDaoDelChannelCache(t *testing.T) {
  97. convey.Convey("DelChannelCache", t, func(ctx convey.C) {
  98. var (
  99. c = context.Background()
  100. mid = int64(0)
  101. cid = int64(0)
  102. )
  103. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  104. err := d.DelChannelCache(c, mid, cid)
  105. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  106. ctx.So(err, convey.ShouldBeNil)
  107. })
  108. })
  109. })
  110. }
  111. func TestDaoChannelListCache(t *testing.T) {
  112. convey.Convey("ChannelListCache", t, func(ctx convey.C) {
  113. var (
  114. c = context.Background()
  115. mid = int64(2222)
  116. )
  117. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  118. channels, err := d.ChannelListCache(c, mid)
  119. ctx.Convey("Then err should be nil.channels should not be nil.", func(ctx convey.C) {
  120. ctx.So(err, convey.ShouldBeNil)
  121. ctx.Printf("%+v", channels)
  122. })
  123. })
  124. })
  125. }
  126. func TestDaoChannelArcsCache(t *testing.T) {
  127. convey.Convey("ChannelArcsCache", t, func(ctx convey.C) {
  128. var (
  129. c = context.Background()
  130. mid = int64(2222)
  131. cid = int64(2222)
  132. start = int(0)
  133. end = int(1)
  134. order bool
  135. )
  136. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  137. arcs, err := d.ChannelArcsCache(c, mid, cid, start, end, order)
  138. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  139. ctx.So(err, convey.ShouldBeNil)
  140. ctx.Printf("%+v", arcs)
  141. })
  142. })
  143. })
  144. }
  145. func TestDaoAddChannelArcCache(t *testing.T) {
  146. convey.Convey("AddChannelArcCache", t, func(ctx convey.C) {
  147. var (
  148. c = context.Background()
  149. mid = int64(2222)
  150. cid = int64(2222)
  151. arcs = []*model.ChannelArc{{ID: 2222, Mid: 2222, Cid: 2222, Aid: 2222}, {ID: 3333, Mid: 3333, Cid: 3333, Aid: 3333}}
  152. )
  153. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  154. err := d.AddChannelArcCache(c, mid, cid, arcs)
  155. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  156. ctx.So(err, convey.ShouldBeNil)
  157. })
  158. })
  159. })
  160. }
  161. func TestDaoSetChannelArcSortCache(t *testing.T) {
  162. convey.Convey("SetChannelArcSortCache", t, func(ctx convey.C) {
  163. var (
  164. c = context.Background()
  165. mid = int64(0)
  166. cid = int64(0)
  167. sort = []*model.ChannelArcSort{{Aid: 4444, OrderNum: 100}, {Aid: 5555, OrderNum: 200}}
  168. )
  169. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  170. err := d.SetChannelArcSortCache(c, mid, cid, sort)
  171. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  172. ctx.So(err, convey.ShouldBeNil)
  173. })
  174. })
  175. })
  176. }
  177. func TestDaoDelChannelArcCache(t *testing.T) {
  178. convey.Convey("DelChannelArcCache", t, func(ctx convey.C) {
  179. var (
  180. c = context.Background()
  181. mid = int64(0)
  182. cid = int64(0)
  183. aid = int64(0)
  184. )
  185. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  186. err := d.DelChannelArcCache(c, mid, cid, aid)
  187. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  188. ctx.So(err, convey.ShouldBeNil)
  189. })
  190. })
  191. })
  192. }
  193. func TestDaoDelChannelArcsCache(t *testing.T) {
  194. convey.Convey("DelChannelArcsCache", t, func(ctx convey.C) {
  195. var (
  196. c = context.Background()
  197. mid = int64(2222)
  198. cid = int64(2222)
  199. )
  200. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  201. err := d.DelChannelArcsCache(c, mid, cid)
  202. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  203. ctx.So(err, convey.ShouldBeNil)
  204. })
  205. })
  206. })
  207. }
  208. func TestDaoSetChannelArcsCache(t *testing.T) {
  209. convey.Convey("SetChannelArcsCache", t, func(ctx convey.C) {
  210. var (
  211. c = context.Background()
  212. mid = int64(2222)
  213. cid = int64(2222)
  214. arcs = []*model.ChannelArc{{ID: 2222, Mid: 2222, Cid: 2222, Aid: 2222}, {ID: 2222, Mid: 2222, Cid: 2222, Aid: 3333}}
  215. )
  216. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  217. err := d.SetChannelArcsCache(c, mid, cid, arcs)
  218. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  219. ctx.So(err, convey.ShouldBeNil)
  220. })
  221. })
  222. })
  223. }