redis_test.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaokeyDM(t *testing.T) {
  8. convey.Convey("keyDM", t, func(ctx convey.C) {
  9. var (
  10. tp = int32(0)
  11. oid = int64(0)
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. key := keyDM(tp, oid)
  15. ctx.Convey("Then key should not be nil.", func(ctx convey.C) {
  16. ctx.So(key, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaokeyBroadcastLimit(t *testing.T) {
  22. convey.Convey("keyBroadcastLimit", t, func(ctx convey.C) {
  23. var (
  24. tp = int32(0)
  25. oid = int64(0)
  26. )
  27. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  28. key := keyBroadcastLimit(tp, oid)
  29. ctx.Convey("Then key should not be nil.", func(ctx convey.C) {
  30. ctx.So(key, convey.ShouldNotBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaoDMCache(t *testing.T) {
  36. convey.Convey("DMCache", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. tp = int32(0)
  40. oid = int64(0)
  41. )
  42. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  43. res, err := testDao.DMCache(c, tp, oid)
  44. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. ctx.So(res, convey.ShouldNotBeNil)
  47. })
  48. })
  49. })
  50. }
  51. func TestDaoExpireDMCache(t *testing.T) {
  52. convey.Convey("ExpireDMCache", t, func(ctx convey.C) {
  53. var (
  54. c = context.Background()
  55. tp = int32(0)
  56. oid = int64(0)
  57. )
  58. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  59. ok, err := testDao.ExpireDMCache(c, tp, oid)
  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 TestDaoTrimDMCache(t *testing.T) {
  68. convey.Convey("TrimDMCache", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. tp = int32(0)
  72. oid = int64(0)
  73. count = int64(0)
  74. )
  75. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  76. err := testDao.TrimDMCache(c, tp, oid, count)
  77. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. })
  80. })
  81. })
  82. }
  83. func TestDaoIncrPubCnt(t *testing.T) {
  84. convey.Convey("IncrPubCnt", t, func(ctx convey.C) {
  85. var (
  86. c = context.Background()
  87. mid = int64(0)
  88. color = int64(0)
  89. mode = int32(0)
  90. fontsize = int32(0)
  91. ip = ""
  92. msg = ""
  93. )
  94. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  95. err := testDao.IncrPubCnt(c, mid, color, mode, fontsize, ip, msg)
  96. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  97. ctx.So(err, convey.ShouldBeNil)
  98. })
  99. })
  100. })
  101. }
  102. func TestDaoPubCnt(t *testing.T) {
  103. convey.Convey("PubCnt", t, func(ctx convey.C) {
  104. var (
  105. c = context.Background()
  106. mid = int64(0)
  107. color = int64(0)
  108. mode = int32(0)
  109. fontsize = int32(0)
  110. ip = ""
  111. msg = ""
  112. )
  113. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  114. count, err := testDao.PubCnt(c, mid, color, mode, fontsize, ip, msg)
  115. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  116. ctx.So(err, convey.ShouldBeNil)
  117. ctx.So(count, convey.ShouldNotBeNil)
  118. })
  119. })
  120. })
  121. }
  122. func TestDaoIncrCharPubCnt(t *testing.T) {
  123. convey.Convey("IncrCharPubCnt", t, func(ctx convey.C) {
  124. var (
  125. c = context.Background()
  126. mid = int64(0)
  127. oid = int64(0)
  128. )
  129. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  130. err := testDao.IncrCharPubCnt(c, mid, oid)
  131. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  132. ctx.So(err, convey.ShouldBeNil)
  133. })
  134. })
  135. })
  136. }
  137. func TestDaoCharPubCnt(t *testing.T) {
  138. convey.Convey("CharPubCnt", t, func(ctx convey.C) {
  139. var (
  140. c = context.Background()
  141. mid = int64(0)
  142. oid = int64(0)
  143. )
  144. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  145. count, err := testDao.CharPubCnt(c, mid, oid)
  146. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  147. ctx.So(err, convey.ShouldBeNil)
  148. ctx.So(count, convey.ShouldNotBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaoDelCharPubCnt(t *testing.T) {
  154. convey.Convey("DelCharPubCnt", t, func(ctx convey.C) {
  155. var (
  156. c = context.Background()
  157. mid = int64(0)
  158. oid = int64(0)
  159. )
  160. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  161. err := testDao.DelCharPubCnt(c, mid, oid)
  162. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  163. ctx.So(err, convey.ShouldBeNil)
  164. })
  165. })
  166. })
  167. }
  168. func TestDaoBroadcastLimit(t *testing.T) {
  169. convey.Convey("BroadcastLimit", t, func(ctx convey.C) {
  170. var (
  171. c = context.Background()
  172. oid = int64(0)
  173. tp = int32(0)
  174. count = int(0)
  175. interval = int(0)
  176. )
  177. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  178. testDao.BroadcastLimit(c, oid, tp, count, interval)
  179. })
  180. })
  181. }