panel_test.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. "go-common/app/admin/main/vip/model"
  8. xtime "go-common/library/time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestDaoAddVipPriceConfig(t *testing.T) {
  12. Convey("Test_AddVipPriceConfig", t, func() {
  13. v := &model.VipPriceConfig{
  14. Plat: 1,
  15. PdName: "ddd",
  16. PdID: "sss",
  17. SuitType: 1,
  18. Month: 1,
  19. SubType: 2,
  20. OPrice: 1,
  21. Selected: 1,
  22. Remark: "",
  23. Status: 0,
  24. Operator: "sss",
  25. OpID: 1,
  26. }
  27. err := d.AddVipPriceConfig(context.TODO(), v)
  28. So(err, ShouldBeNil)
  29. })
  30. Convey("Test_AddVipPriceConfig add build 200-300", t, func() {
  31. v := &model.VipPriceConfig{
  32. Plat: 10,
  33. PdName: "ddd",
  34. PdID: "sss",
  35. SuitType: 1,
  36. Month: 1,
  37. SubType: 1,
  38. OPrice: 1,
  39. Selected: 1,
  40. Remark: "",
  41. Status: 0,
  42. Operator: "sss",
  43. OpID: 1,
  44. StartBuild: 200,
  45. EndBuild: 300,
  46. }
  47. err := d.AddVipPriceConfig(context.TODO(), v)
  48. So(err, ShouldBeNil)
  49. })
  50. Convey("Test_AddVipPriceConfig add build 0-0", t, func() {
  51. v := &model.VipPriceConfig{
  52. Plat: 10,
  53. PdName: "ddd",
  54. PdID: "sss",
  55. SuitType: 1,
  56. Month: 1,
  57. SubType: 1,
  58. OPrice: 1,
  59. Selected: 1,
  60. Remark: "",
  61. Status: 0,
  62. Operator: "sss",
  63. OpID: 1,
  64. StartBuild: 200,
  65. EndBuild: 300,
  66. }
  67. err := d.AddVipPriceConfig(context.TODO(), v)
  68. So(err, ShouldBeNil)
  69. })
  70. }
  71. func TestDaoAddVipDPriceConfig(t *testing.T) {
  72. Convey("Test_AddVipPriceConfig", t, func() {
  73. v := &model.VipDPriceConfig{
  74. DisID: 1,
  75. ID: 1,
  76. PdID: "sss",
  77. DPrice: 1,
  78. STime: xtime.Time(time.Now().Unix()),
  79. Remark: "",
  80. Operator: "sss",
  81. OpID: 1,
  82. }
  83. err := d.AddVipDPriceConfig(context.TODO(), v)
  84. So(err, ShouldBeNil)
  85. })
  86. }
  87. func TestUpVipPriceConfig(t *testing.T) {
  88. Convey("TestUpVipPriceConfig", t, func() {
  89. err := d.UpVipPriceConfig(context.TODO(), &model.VipPriceConfig{
  90. ID: 230,
  91. Plat: 10,
  92. PdName: "ddd",
  93. PdID: "sss",
  94. SuitType: 1,
  95. Month: 1,
  96. SubType: 1,
  97. OPrice: 1,
  98. Selected: 1,
  99. Remark: "",
  100. Status: 0,
  101. Operator: "sss",
  102. OpID: 1,
  103. StartBuild: 250,
  104. EndBuild: 300,
  105. })
  106. So(err, ShouldBeNil)
  107. })
  108. }
  109. func TestDaoUpVipPriceConfig(t *testing.T) {
  110. Convey("Test_UpVipPriceConfig", t, func() {
  111. v := &model.VipPriceConfig{
  112. ID: 1,
  113. Plat: 1,
  114. PdName: "ddd",
  115. PdID: "sss",
  116. SuitType: 1,
  117. Month: 1,
  118. SubType: 2,
  119. OPrice: 1,
  120. Selected: 1,
  121. Remark: "",
  122. Status: 0,
  123. Operator: "sss",
  124. OpID: 1,
  125. }
  126. err := d.AddVipPriceConfig(context.TODO(), v)
  127. So(err, ShouldBeNil)
  128. })
  129. }
  130. func TestDaoUpVipDPriceConfig(t *testing.T) {
  131. Convey("Test_UpVipDPriceConfig", t, func() {
  132. v := &model.VipDPriceConfig{
  133. DisID: 1,
  134. ID: 1,
  135. PdID: "sss",
  136. DPrice: 1,
  137. STime: xtime.Time(time.Now().Unix()),
  138. Remark: "",
  139. Operator: "sss",
  140. OpID: 1,
  141. }
  142. err := d.UpVipDPriceConfig(context.TODO(), v)
  143. So(err, ShouldBeNil)
  144. })
  145. }
  146. func TestDaoDelVipPriceConfig(t *testing.T) {
  147. Convey("Test_DelVipPriceConfig", t, func() {
  148. err := d.DelVipPriceConfig(context.TODO(), &model.ArgVipPriceID{ID: 1})
  149. So(err, ShouldBeNil)
  150. })
  151. }
  152. func TestDaoDelVipDPriceConfig(t *testing.T) {
  153. Convey("Test_DelVipDPriceConfig", t, func() {
  154. err := d.DelVipDPriceConfig(context.TODO(), &model.ArgVipDPriceID{DisID: 1})
  155. So(err, ShouldBeNil)
  156. })
  157. }
  158. func TestDaoVipPriceConfigUQCheck(t *testing.T) {
  159. Convey("Test_VipPriceConfigUQCheck", t, func() {
  160. res, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 1, Month: 1, SubType: 1, SuitType: 0})
  161. So(err, ShouldBeNil)
  162. So(res, ShouldNotBeNil)
  163. })
  164. Convey("Test_VipPriceConfigUQCheck count 0-0", t, func() {
  165. count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1})
  166. fmt.Println("count:", count)
  167. So(err, ShouldBeNil)
  168. So(count, ShouldNotBeNil)
  169. })
  170. Convey("Test_VipPriceConfigUQCheck count 220-0", t, func() {
  171. count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 220, EndBuild: 0})
  172. fmt.Println("count:", count)
  173. So(err, ShouldBeNil)
  174. So(count, ShouldNotBeNil)
  175. })
  176. Convey("Test_VipPriceConfigUQCheck count 120-180", t, func() {
  177. count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 120, EndBuild: 180})
  178. fmt.Println("count:", count)
  179. So(err, ShouldBeNil)
  180. So(count, ShouldNotBeNil)
  181. })
  182. Convey("Test_VipPriceConfigUQCheck count 0-180", t, func() {
  183. count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 0, EndBuild: 180})
  184. fmt.Println("count:", count)
  185. So(err, ShouldBeNil)
  186. So(count, ShouldNotBeNil)
  187. })
  188. Convey("Test_VipPriceConfigUQCheck count 0-600", t, func() {
  189. count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 0, EndBuild: 600})
  190. fmt.Println("count:", count)
  191. So(err, ShouldBeNil)
  192. So(count, ShouldNotBeNil)
  193. })
  194. }
  195. func TestDaoVipPriceConfigs(t *testing.T) {
  196. Convey("Test_VipPriceConfigs", t, func() {
  197. count, err := d.VipPriceConfigs(context.TODO())
  198. So(err, ShouldBeNil)
  199. So(count, ShouldNotBeEmpty)
  200. })
  201. }
  202. func TestDaoVipPriceConfigID(t *testing.T) {
  203. Convey("Test_VipPriceConfigID", t, func() {
  204. ids, err := d.VipPriceConfigID(context.TODO(), &model.ArgVipPriceID{ID: 1})
  205. So(err, ShouldBeNil)
  206. So(ids, ShouldNotBeEmpty)
  207. })
  208. }
  209. func TestDaoVipDPriceConfigs(t *testing.T) {
  210. Convey("Test_VipDPriceConfigs", t, func() {
  211. count, err := d.VipDPriceConfigs(context.TODO(), &model.ArgVipPriceID{ID: 1})
  212. So(err, ShouldBeNil)
  213. So(count, ShouldNotBeEmpty)
  214. })
  215. }
  216. func TestDaoVipDPriceConfigID(t *testing.T) {
  217. Convey("Test_VipDPriceConfigID", t, func() {
  218. res, err := d.VipDPriceConfigID(context.TODO(), &model.ArgVipDPriceID{DisID: 1})
  219. So(err, ShouldBeNil)
  220. So(res, ShouldNotBeEmpty)
  221. })
  222. }
  223. func TestDaoVipDPriceConfigUQTime(t *testing.T) {
  224. Convey("Test_VipDPriceConfigUQTime", t, func() {
  225. arg := &model.ArgAddOrUpVipDPrice{
  226. ID: 992,
  227. STime: xtime.Time(time.Now().Unix()),
  228. ETime: xtime.Time(time.Now().Unix()),
  229. }
  230. _, err := d.VipDPriceConfigUQTime(context.TODO(), arg)
  231. So(err, ShouldBeNil)
  232. })
  233. }
  234. func TestDaoVipPriceDiscountConfigs(t *testing.T) {
  235. Convey("Test_VipPriceDiscountConfigs", t, func() {
  236. res, err := d.VipPriceDiscountConfigs(context.TODO())
  237. So(err, ShouldBeNil)
  238. So(res, ShouldNotBeEmpty)
  239. })
  240. }
  241. func TestDaoVipMaxPriceDiscount(t *testing.T) {
  242. Convey("Test_VipMaxPriceDiscount", t, func() {
  243. res, err := d.VipMaxPriceDiscount(context.TODO(), &model.ArgAddOrUpVipPrice{ID: 1})
  244. So(err, ShouldBeNil)
  245. So(res, ShouldNotBeEmpty)
  246. })
  247. }
  248. func TestDaoCountVipPriceConfigByPlat(t *testing.T) {
  249. Convey("TestDaoCountVipPriceConfigByPlat", t, func() {
  250. res, err := d.CountVipPriceConfigByPlat(context.TODO(), 1)
  251. fmt.Println(res)
  252. So(err, ShouldBeNil)
  253. So(res, ShouldBeGreaterThanOrEqualTo, 0)
  254. })
  255. }