redis_test.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/reply/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyIdx(t *testing.T) {
  9. convey.Convey("keyIdx", t, func(ctx convey.C) {
  10. var (
  11. oid = int64(0)
  12. tp = int32(0)
  13. sort = int32(0)
  14. )
  15. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  16. p1 := keyIdx(oid, tp, sort)
  17. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  18. ctx.So(p1, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaokeyNewRootIdx(t *testing.T) {
  24. convey.Convey("keyNewRootIdx", t, func(ctx convey.C) {
  25. var (
  26. rpID = int64(0)
  27. )
  28. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  29. p1 := keyNewRootIdx(rpID)
  30. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  31. ctx.So(p1, convey.ShouldNotBeNil)
  32. })
  33. })
  34. })
  35. }
  36. func TestDaokeyAuditIdx(t *testing.T) {
  37. convey.Convey("keyAuditIdx", t, func(ctx convey.C) {
  38. var (
  39. oid = int64(0)
  40. tp = int32(0)
  41. )
  42. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  43. p1 := keyAuditIdx(oid, tp)
  44. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  45. ctx.So(p1, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoExpireIndex(t *testing.T) {
  51. convey.Convey("ExpireIndex", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. oid = int64(0)
  55. typ = int32(0)
  56. sort = int32(0)
  57. )
  58. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  59. ok, err := _d.ExpireIndex(c, oid, typ, sort)
  60. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. ctx.So(ok, convey.ShouldNotBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoExpireNewChildIndex(t *testing.T) {
  68. convey.Convey("ExpireNewChildIndex", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. root = int64(0)
  72. )
  73. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  74. ok, err := _d.ExpireNewChildIndex(c, root)
  75. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldBeNil)
  77. ctx.So(ok, convey.ShouldNotBeNil)
  78. })
  79. })
  80. })
  81. }
  82. func TestDaoCountReplies(t *testing.T) {
  83. convey.Convey("CountReplies", t, func(ctx convey.C) {
  84. var (
  85. c = context.Background()
  86. oid = int64(0)
  87. tp = int32(0)
  88. sort = int32(0)
  89. )
  90. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  91. count, err := _d.CountReplies(c, oid, tp, sort)
  92. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(count, convey.ShouldNotBeNil)
  95. })
  96. })
  97. })
  98. }
  99. func TestDaoMinScore(t *testing.T) {
  100. convey.Convey("MinScore", t, func(ctx convey.C) {
  101. var (
  102. c = context.Background()
  103. oid = int64(0)
  104. tp = int32(0)
  105. sort = int32(1)
  106. )
  107. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  108. score, err := _d.MinScore(c, oid, tp, sort)
  109. ctx.Convey("Then err should be nil.score should not be nil.", func(ctx convey.C) {
  110. if err != nil {
  111. ctx.So(err, convey.ShouldNotBeNil)
  112. }
  113. ctx.So(score, convey.ShouldEqual, 0)
  114. })
  115. })
  116. })
  117. }
  118. func TestDaoAddFloorIndex(t *testing.T) {
  119. convey.Convey("AddFloorIndex", t, func(ctx convey.C) {
  120. var (
  121. c = context.Background()
  122. rp = &model.Reply{}
  123. )
  124. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  125. err := _d.AddFloorIndex(c, rp)
  126. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  127. ctx.So(err, convey.ShouldBeNil)
  128. })
  129. })
  130. })
  131. }
  132. func TestDaoAddCountIndex(t *testing.T) {
  133. convey.Convey("AddCountIndex", t, func(ctx convey.C) {
  134. var (
  135. c = context.Background()
  136. rp = &model.Reply{}
  137. )
  138. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  139. err := _d.AddCountIndex(c, rp)
  140. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  141. ctx.So(err, convey.ShouldBeNil)
  142. })
  143. })
  144. })
  145. }
  146. func TestDaoAddLikeIndex(t *testing.T) {
  147. convey.Convey("AddLikeIndex", t, func(ctx convey.C) {
  148. var (
  149. c = context.Background()
  150. rp = &model.Reply{}
  151. rpt = &model.Report{}
  152. )
  153. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  154. err := _d.AddLikeIndex(c, rp, rpt)
  155. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  156. ctx.So(err, convey.ShouldBeNil)
  157. })
  158. })
  159. })
  160. }
  161. func TestDaoDelIndexBySort(t *testing.T) {
  162. convey.Convey("DelIndexBySort", t, func(ctx convey.C) {
  163. var (
  164. c = context.Background()
  165. rp = &model.Reply{}
  166. sort = int32(0)
  167. )
  168. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  169. err := _d.DelIndexBySort(c, rp, sort)
  170. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  171. ctx.So(err, convey.ShouldBeNil)
  172. })
  173. })
  174. })
  175. }
  176. func TestDaoDelReplyIndex(t *testing.T) {
  177. convey.Convey("DelReplyIndex", t, func(ctx convey.C) {
  178. var (
  179. c = context.Background()
  180. rp = &model.Reply{}
  181. )
  182. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  183. err := _d.DelReplyIndex(c, rp)
  184. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  185. ctx.So(err, convey.ShouldBeNil)
  186. })
  187. })
  188. })
  189. }
  190. func TestDaoAddNewChildIndex(t *testing.T) {
  191. convey.Convey("AddNewChildIndex", t, func(ctx convey.C) {
  192. var (
  193. c = context.Background()
  194. rp = &model.Reply{}
  195. )
  196. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  197. err := _d.AddNewChildIndex(c, rp)
  198. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  199. ctx.So(err, convey.ShouldBeNil)
  200. })
  201. })
  202. })
  203. }
  204. func TestDaoDelAuditIndex(t *testing.T) {
  205. convey.Convey("DelAuditIndex", t, func(ctx convey.C) {
  206. var (
  207. c = context.Background()
  208. rp = &model.Reply{}
  209. )
  210. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  211. err := _d.DelAuditIndex(c, rp)
  212. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  213. ctx.So(err, convey.ShouldBeNil)
  214. })
  215. })
  216. })
  217. }