mc.cache_test.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/ugcpay/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoAddCacheOrderUser(t *testing.T) {
  9. convey.Convey("AddCacheOrderUser", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. id = "test"
  13. val = &model.Order{}
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. err := d.AddCacheOrderUser(c, id, val)
  17. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoCacheOrderUser(t *testing.T) {
  24. convey.Convey("CacheOrderUser", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. id = "test"
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. res, err := d.CacheOrderUser(c, id)
  31. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(res, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoDelCacheOrderUser(t *testing.T) {
  39. convey.Convey("DelCacheOrderUser", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. id = "test"
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. err := d.DelCacheOrderUser(c, id)
  46. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. })
  49. })
  50. })
  51. }
  52. func TestDaoAddCacheAsset(t *testing.T) {
  53. convey.Convey("AddCacheAsset", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. id = int64(233333)
  57. otype = "archive"
  58. currency = "bp"
  59. value = &model.Asset{}
  60. )
  61. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  62. err := d.AddCacheAsset(c, id, otype, currency, value)
  63. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoCacheAsset(t *testing.T) {
  70. convey.Convey("CacheAsset", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. id = int64(233333)
  74. otype = "archive"
  75. currency = "bp"
  76. )
  77. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  78. res, err := d.CacheAsset(c, id, otype, currency)
  79. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  80. ctx.So(err, convey.ShouldBeNil)
  81. ctx.So(res, convey.ShouldNotBeNil)
  82. })
  83. })
  84. })
  85. }
  86. func TestDaoDelCacheAsset(t *testing.T) {
  87. convey.Convey("DelCacheAsset", t, func(ctx convey.C) {
  88. var (
  89. c = context.Background()
  90. id = int64(233333)
  91. otype = "archive"
  92. currency = "bp"
  93. )
  94. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  95. err := d.DelCacheAsset(c, id, otype, currency)
  96. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  97. ctx.So(err, convey.ShouldBeNil)
  98. })
  99. })
  100. })
  101. }
  102. // func TestDaoCacheAggrIncomeUser(t *testing.T) {
  103. // convey.Convey("CacheAggrIncomeUser", t, func(ctx convey.C) {
  104. // var (
  105. // c = context.Background()
  106. // id = int64(46333)
  107. // cur = "bp"
  108. // )
  109. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  110. // res, err := d.CacheAggrIncomeUser(c, id, cur)
  111. // ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  112. // ctx.So(err, convey.ShouldBeNil)
  113. // ctx.So(res, convey.ShouldNotBeNil)
  114. // })
  115. // })
  116. // })
  117. // }
  118. // func TestDaoAddCacheAggrIncomeUser(t *testing.T) {
  119. // convey.Convey("AddCacheAggrIncomeUser", t, func(ctx convey.C) {
  120. // var (
  121. // c = context.Background()
  122. // id = int64(46333)
  123. // val = &model.AggrIncomeUser{}
  124. // cur = "bp"
  125. // )
  126. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. // err := d.AddCacheAggrIncomeUser(c, id, cur, val)
  128. // ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  129. // ctx.So(err, convey.ShouldBeNil)
  130. // })
  131. // })
  132. // })
  133. // }
  134. // func TestDaoDelCacheAggrIncomeUser(t *testing.T) {
  135. // convey.Convey("DelCacheAggrIncomeUser", t, func(ctx convey.C) {
  136. // var (
  137. // c = context.Background()
  138. // id = int64(46333)
  139. // cur = "bp"
  140. // )
  141. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  142. // err := d.DelCacheAggrIncomeUser(c, id, cur)
  143. // ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  144. // ctx.So(err, convey.ShouldBeNil)
  145. // })
  146. // })
  147. // })
  148. // }
  149. // func TestDaoCacheAggrIncomeUserMonthly(t *testing.T) {
  150. // convey.Convey("CacheAggrIncomeUserMonthly", t, func(ctx convey.C) {
  151. // var (
  152. // c = context.Background()
  153. // id = int64(46333)
  154. // ver = int64(123)
  155. // cur = "bp"
  156. // )
  157. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  158. // res, err := d.CacheAggrIncomeUserAssetList(c, id, cur, ver)
  159. // ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  160. // ctx.So(err, convey.ShouldBeNil)
  161. // ctx.So(res, convey.ShouldNotBeNil)
  162. // })
  163. // })
  164. // })
  165. // }
  166. // func TestDaoAddCacheAggrIncomeUserMonthly(t *testing.T) {
  167. // convey.Convey("AddCacheAggrIncomeUserMonthly", t, func(ctx convey.C) {
  168. // var (
  169. // c = context.Background()
  170. // id = int64(46333)
  171. // ver = int64(123)
  172. // cur = "bp"
  173. // value = []*model.AggrIncomeUserAsset{}
  174. // )
  175. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  176. // err := d.AddCacheAggrIncomeUserAssetList(c, id, cur, ver, value)
  177. // ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  178. // ctx.So(err, convey.ShouldBeNil)
  179. // })
  180. // })
  181. // })
  182. // }
  183. // func TestDaoDelCacheAggrIncomeUserMonthly(t *testing.T) {
  184. // convey.Convey("DelCacheAggrIncomeUserMonthly", t, func(ctx convey.C) {
  185. // var (
  186. // c = context.Background()
  187. // id = int64(46333)
  188. // ver = int64(123)
  189. // cur = "bp"
  190. // )
  191. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  192. // err := d.DelCacheAggrIncomeUserAssetList(c, id, cur, ver)
  193. // ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  194. // ctx.So(err, convey.ShouldBeNil)
  195. // })
  196. // })
  197. // })
  198. // }