welfare_test.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/vip/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoGetWelfareList(t *testing.T) {
  9. convey.Convey("GetWelfareList", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. req = &model.ArgWelfareList{}
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. _, err := d.GetWelfareList(c, req)
  16. ctx.Convey("Then err should be nil", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoCountWelfare(t *testing.T) {
  23. convey.Convey("CountWelfare", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. req = &model.ArgWelfareList{}
  27. )
  28. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  29. count, err := d.CountWelfare(c, req)
  30. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. ctx.So(count, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestDaoGetRecommendWelfare(t *testing.T) {
  38. convey.Convey("GetRecommendWelfare", t, func(ctx convey.C) {
  39. var (
  40. c = context.Background()
  41. req = &model.ArgWelfareList{}
  42. )
  43. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  44. _, err := d.GetRecommendWelfare(c, req)
  45. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  46. ctx.So(err, convey.ShouldBeNil)
  47. })
  48. })
  49. })
  50. }
  51. func TestDaoCountRecommendWelfare(t *testing.T) {
  52. convey.Convey("CountRecommendWelfare", t, func(ctx convey.C) {
  53. var (
  54. c = context.Background()
  55. req = &model.ArgWelfareList{}
  56. )
  57. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  58. count, err := d.CountRecommendWelfare(c, req)
  59. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  60. ctx.So(err, convey.ShouldBeNil)
  61. ctx.So(count, convey.ShouldNotBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaoGetWelfareTypeList(t *testing.T) {
  67. convey.Convey("GetWelfareTypeList", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. )
  71. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  72. res, err := d.GetWelfareTypeList(c)
  73. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  74. ctx.So(err, convey.ShouldBeNil)
  75. ctx.So(res, convey.ShouldNotBeNil)
  76. })
  77. })
  78. })
  79. }
  80. func TestDaoGetWelfareInfo(t *testing.T) {
  81. convey.Convey("GetWelfareInfo", t, func(ctx convey.C) {
  82. var (
  83. c = context.Background()
  84. id = int64(0)
  85. )
  86. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  87. _, err := d.GetWelfareInfo(c, id)
  88. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldBeNil)
  90. })
  91. })
  92. })
  93. }
  94. func TestDaoGetWelfareBatch(t *testing.T) {
  95. convey.Convey("GetWelfareBatch", t, func(ctx convey.C) {
  96. var (
  97. c = context.Background()
  98. wid = int64(0)
  99. )
  100. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  101. _, err := d.GetWelfareBatch(c, wid)
  102. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  103. ctx.So(err, convey.ShouldBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDaoGetReceivedCode(t *testing.T) {
  109. convey.Convey("GetReceivedCode", t, func(ctx convey.C) {
  110. var (
  111. c = context.Background()
  112. wid = int64(0)
  113. mid = int64(0)
  114. )
  115. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  116. _, err := d.GetReceivedCode(c, wid, mid)
  117. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  118. ctx.So(err, convey.ShouldBeNil)
  119. })
  120. })
  121. })
  122. }
  123. func TestDaoUpdateWelfareCodeUser(t *testing.T) {
  124. convey.Convey("UpdateWelfareCodeUser", t, func(ctx convey.C) {
  125. var (
  126. c = context.Background()
  127. id = int(0)
  128. mid = int64(0)
  129. )
  130. tx, _ := d.StartTx(c)
  131. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  132. res, err := d.UpdateWelfareCodeUser(c, tx, id, mid)
  133. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  134. ctx.So(err, convey.ShouldBeNil)
  135. ctx.So(res, convey.ShouldNotBeNil)
  136. })
  137. })
  138. })
  139. }
  140. func TestDaoUpdateWelfareBatch(t *testing.T) {
  141. convey.Convey("UpdateWelfareBatch", t, func(ctx convey.C) {
  142. var (
  143. c = context.Background()
  144. bid = int(0)
  145. )
  146. tx, err := d.StartTx(c)
  147. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  148. err = d.UpdateWelfareBatch(c, tx, bid)
  149. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldBeNil)
  151. })
  152. })
  153. })
  154. }
  155. func TestDaoGetWelfareCodeUnReceived(t *testing.T) {
  156. convey.Convey("GetWelfareCodeUnReceived", t, func(ctx convey.C) {
  157. var (
  158. c = context.Background()
  159. wid = int64(0)
  160. bids = []string{}
  161. )
  162. bids = append(bids, "1")
  163. bids = append(bids, "2")
  164. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  165. _, err := d.GetWelfareCodeUnReceived(c, wid, bids)
  166. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  167. ctx.So(err, convey.ShouldBeNil)
  168. })
  169. })
  170. })
  171. }
  172. func TestDaoGetMyWelfare(t *testing.T) {
  173. convey.Convey("GetMyWelfare", t, func(ctx convey.C) {
  174. var (
  175. c = context.Background()
  176. mid = int64(0)
  177. )
  178. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  179. _, err := d.GetMyWelfare(c, mid)
  180. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  181. ctx.So(err, convey.ShouldBeNil)
  182. })
  183. })
  184. })
  185. }
  186. func TestDaoAddReceiveRedirectWelfare(t *testing.T) {
  187. convey.Convey("AddReceiveRedirectWelfare", t, func(ctx convey.C) {
  188. var (
  189. c = context.Background()
  190. wid = int64(0)
  191. mid = int64(0)
  192. )
  193. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  194. err := d.AddReceiveRedirectWelfare(c, wid, mid)
  195. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  196. ctx.So(err, convey.ShouldBeNil)
  197. })
  198. })
  199. })
  200. }
  201. func TestDaoCountReceiveRedirectWelfare(t *testing.T) {
  202. convey.Convey("CountReceiveRedirectWelfare", t, func(ctx convey.C) {
  203. var (
  204. c = context.Background()
  205. wid = int64(0)
  206. mid = int64(0)
  207. )
  208. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  209. count, err := d.CountReceiveRedirectWelfare(c, wid, mid)
  210. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  211. ctx.So(err, convey.ShouldBeNil)
  212. ctx.So(count, convey.ShouldNotBeNil)
  213. })
  214. })
  215. })
  216. }
  217. func TestDaoInsertReceiveRecord(t *testing.T) {
  218. convey.Convey("InsertReceiveRecord", t, func(ctx convey.C) {
  219. var (
  220. c = context.Background()
  221. wid = int64(0)
  222. mid = int64(0)
  223. monthYear = int64(0)
  224. )
  225. tx, err := d.StartTx(c)
  226. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  227. err = d.InsertReceiveRecord(c, tx, wid, mid, monthYear)
  228. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  229. ctx.So(err, convey.ShouldBeNil)
  230. })
  231. })
  232. })
  233. }