mc.cache_test.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 TestDaoAddCacheNotice(t *testing.T) {
  9. convey.Convey("AddCacheNotice", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. id = int64(2222)
  13. val = &model.Notice{Notice: "2222"}
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. err := d.AddCacheNotice(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 TestDaoCacheNotice(t *testing.T) {
  24. convey.Convey("CacheNotice", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. id = int64(2222)
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. res, err := d.CacheNotice(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 TestDaoDelCacheNotice(t *testing.T) {
  39. convey.Convey("DelCacheNotice", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. id = int64(2222)
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. err := d.DelCacheNotice(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 TestDaoAddCacheTopArc(t *testing.T) {
  53. convey.Convey("AddCacheTopArc", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. id = int64(2222)
  57. val = &model.AidReason{Aid: 2222, Reason: "2222"}
  58. )
  59. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  60. err := d.AddCacheTopArc(c, id, val)
  61. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoCacheTopArc(t *testing.T) {
  68. convey.Convey("CacheTopArc", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. id = int64(2222)
  72. )
  73. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  74. res, err := d.CacheTopArc(c, id)
  75. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldBeNil)
  77. ctx.So(res, convey.ShouldNotBeNil)
  78. })
  79. })
  80. })
  81. }
  82. func TestDaoAddCacheMasterpiece(t *testing.T) {
  83. convey.Convey("AddCacheMasterpiece", t, func(ctx convey.C) {
  84. var (
  85. c = context.Background()
  86. id = int64(2222)
  87. val = &model.AidReasons{List: []*model.AidReason{{Aid: 2222, Reason: "2222"}}}
  88. )
  89. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  90. err := d.AddCacheMasterpiece(c, id, val)
  91. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  92. ctx.So(err, convey.ShouldBeNil)
  93. })
  94. })
  95. })
  96. }
  97. func TestDaoCacheMasterpiece(t *testing.T) {
  98. convey.Convey("CacheMasterpiece", t, func(ctx convey.C) {
  99. var (
  100. c = context.Background()
  101. id = int64(2222)
  102. )
  103. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  104. res, err := d.CacheMasterpiece(c, id)
  105. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  106. ctx.So(err, convey.ShouldBeNil)
  107. ctx.So(res, convey.ShouldNotBeNil)
  108. })
  109. })
  110. })
  111. }
  112. func TestDaoAddCacheTheme(t *testing.T) {
  113. convey.Convey("AddCacheTheme", t, func(ctx convey.C) {
  114. var (
  115. c = context.Background()
  116. id = int64(2222)
  117. val = &model.ThemeDetails{}
  118. )
  119. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  120. err := d.AddCacheTheme(c, id, val)
  121. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  122. ctx.So(err, convey.ShouldBeNil)
  123. })
  124. })
  125. })
  126. }
  127. func TestDaoCacheTheme(t *testing.T) {
  128. convey.Convey("CacheTheme", t, func(ctx convey.C) {
  129. var (
  130. c = context.Background()
  131. id = int64(2222)
  132. )
  133. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  134. res, err := d.CacheTheme(c, id)
  135. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  136. ctx.So(err, convey.ShouldBeNil)
  137. ctx.So(res, convey.ShouldNotBeNil)
  138. })
  139. })
  140. })
  141. }
  142. func TestDaoDelCacheTheme(t *testing.T) {
  143. convey.Convey("DelCacheTheme", t, func(ctx convey.C) {
  144. var (
  145. c = context.Background()
  146. id = int64(0)
  147. )
  148. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  149. err := d.DelCacheTheme(c, id)
  150. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  151. ctx.So(err, convey.ShouldBeNil)
  152. })
  153. })
  154. })
  155. }
  156. func TestDaoAddCacheTopDynamic(t *testing.T) {
  157. convey.Convey("AddCacheTopDynamic", t, func(ctx convey.C) {
  158. var (
  159. c = context.Background()
  160. id = int64(2222)
  161. val = int64(2222)
  162. )
  163. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  164. err := d.AddCacheTopDynamic(c, id, val)
  165. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  166. ctx.So(err, convey.ShouldBeNil)
  167. })
  168. })
  169. })
  170. }
  171. func TestDaoCacheTopDynamic(t *testing.T) {
  172. convey.Convey("CacheTopDynamic", t, func(ctx convey.C) {
  173. var (
  174. c = context.Background()
  175. id = int64(2222)
  176. )
  177. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  178. res, err := d.CacheTopDynamic(c, id)
  179. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  180. ctx.So(err, convey.ShouldBeNil)
  181. ctx.So(res, convey.ShouldNotBeNil)
  182. })
  183. })
  184. })
  185. }