memcache_test.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/vip/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaopointTip(t *testing.T) {
  9. var (
  10. mid = int64(0)
  11. id = int64(0)
  12. )
  13. convey.Convey("pointTip", t, func(ctx convey.C) {
  14. p1 := pointTip(mid, id)
  15. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. }
  20. func TestDaoopenCode(t *testing.T) {
  21. var (
  22. mid = int64(0)
  23. )
  24. convey.Convey("openCode", t, func(ctx convey.C) {
  25. p1 := openCode(mid)
  26. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  27. ctx.So(p1, convey.ShouldNotBeNil)
  28. })
  29. })
  30. }
  31. func TestDaovipInfoKey(t *testing.T) {
  32. var (
  33. mid = int64(0)
  34. )
  35. convey.Convey("vipInfoKey", t, func(ctx convey.C) {
  36. p1 := vipInfoKey(mid)
  37. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  38. ctx.So(p1, convey.ShouldNotBeNil)
  39. })
  40. })
  41. }
  42. func TestDaosignVip(t *testing.T) {
  43. var (
  44. mid = int64(0)
  45. )
  46. convey.Convey("signVip", t, func(ctx convey.C) {
  47. p1 := signVip(mid)
  48. ctx.Convey("p1 should not be nil", func(ctx convey.C) {
  49. ctx.So(p1, convey.ShouldNotBeNil)
  50. })
  51. })
  52. }
  53. func TestDaoDelVipInfoCache(t *testing.T) {
  54. var (
  55. c = context.TODO()
  56. mid = int64(0)
  57. )
  58. convey.Convey("DelVipInfoCache", t, func(ctx convey.C) {
  59. err := d.DelVipInfoCache(c, mid)
  60. ctx.Convey("Error should be nil", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. }
  65. func TestDaopingMC(t *testing.T) {
  66. var (
  67. c = context.TODO()
  68. )
  69. convey.Convey("pingMC", t, func(ctx convey.C) {
  70. err := d.pingMC(c)
  71. ctx.Convey("Error should be nil", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. }
  76. func TestDaoSetVipInfoCache(t *testing.T) {
  77. var (
  78. c = context.TODO()
  79. mid = int64(0)
  80. v = &model.VipInfo{}
  81. )
  82. convey.Convey("SetVipInfoCache", t, func(ctx convey.C) {
  83. err := d.SetVipInfoCache(c, mid, v)
  84. ctx.Convey("Error should be nil", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. })
  87. })
  88. }
  89. func TestDaoVipInfoCache(t *testing.T) {
  90. var (
  91. c = context.TODO()
  92. mid = int64(0)
  93. )
  94. convey.Convey("VipInfoCache", t, func(ctx convey.C) {
  95. _, err := d.VipInfoCache(c, mid)
  96. ctx.Convey("Error should be nil", func(ctx convey.C) {
  97. ctx.So(err, convey.ShouldBeNil)
  98. })
  99. })
  100. }
  101. func TestDaodelCache(t *testing.T) {
  102. var (
  103. c = context.TODO()
  104. key = "key"
  105. )
  106. convey.Convey("delCache", t, func(ctx convey.C) {
  107. err := d.DelCache(c, key)
  108. ctx.Convey("Error should be nil", func(ctx convey.C) {
  109. ctx.So(err, convey.ShouldBeNil)
  110. })
  111. })
  112. }
  113. func TestDaoGetOpenCodeCount(t *testing.T) {
  114. var (
  115. c = context.TODO()
  116. mid = int64(0)
  117. )
  118. convey.Convey("GetOpenCodeCount", t, func(ctx convey.C) {
  119. val, err := d.GetOpenCodeCount(c, mid)
  120. ctx.Convey("Error should be nil", func(ctx convey.C) {
  121. ctx.So(err, convey.ShouldBeNil)
  122. })
  123. ctx.Convey("val should not be nil", func(ctx convey.C) {
  124. ctx.So(val, convey.ShouldNotBeNil)
  125. })
  126. })
  127. }
  128. func TestDaoSetOpenCode(t *testing.T) {
  129. var (
  130. c = context.TODO()
  131. mid = int64(0)
  132. count = int(0)
  133. )
  134. convey.Convey("SetOpenCode", t, func(ctx convey.C) {
  135. err := d.SetOpenCode(c, mid, count)
  136. ctx.Convey("Error should be nil", func(ctx convey.C) {
  137. ctx.So(err, convey.ShouldBeNil)
  138. })
  139. })
  140. }
  141. func TestDaoGetPointTip(t *testing.T) {
  142. var (
  143. c = context.TODO()
  144. mid = int64(0)
  145. id = int64(0)
  146. )
  147. convey.Convey("GetPointTip", t, func(ctx convey.C) {
  148. val, err := d.GetPointTip(c, mid, id)
  149. ctx.Convey("Error should be nil", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldBeNil)
  151. })
  152. ctx.Convey("val should not be nil", func(ctx convey.C) {
  153. ctx.So(val, convey.ShouldNotBeNil)
  154. })
  155. })
  156. }
  157. func TestDaoSetPointTip(t *testing.T) {
  158. var (
  159. c = context.TODO()
  160. mid = int64(0)
  161. id = int64(0)
  162. val = int(0)
  163. expired = int32(0)
  164. )
  165. convey.Convey("SetPointTip", t, func(ctx convey.C) {
  166. err := d.SetPointTip(c, mid, id, val, expired)
  167. ctx.Convey("Error should be nil", func(ctx convey.C) {
  168. ctx.So(err, convey.ShouldBeNil)
  169. })
  170. })
  171. }
  172. func TestDaoSetSignVip(t *testing.T) {
  173. var (
  174. c = context.TODO()
  175. mid = int64(0)
  176. no = int(0)
  177. )
  178. convey.Convey("SetSignVip", t, func(ctx convey.C) {
  179. err := d.SetSignVip(c, mid, no)
  180. ctx.Convey("Error should be nil", func(ctx convey.C) {
  181. ctx.So(err, convey.ShouldBeNil)
  182. })
  183. })
  184. }
  185. func TestDaoGetSignVip(t *testing.T) {
  186. var (
  187. c = context.TODO()
  188. mid = int64(0)
  189. )
  190. convey.Convey("GetSignVip", t, func(ctx convey.C) {
  191. val, err := d.GetSignVip(c, mid)
  192. ctx.Convey("Error should be nil", func(ctx convey.C) {
  193. ctx.So(err, convey.ShouldBeNil)
  194. })
  195. ctx.Convey("val should not be nil", func(ctx convey.C) {
  196. ctx.So(val, convey.ShouldNotBeNil)
  197. })
  198. })
  199. }