month_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/vip/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. var (
  9. ctx = context.TODO()
  10. )
  11. func Test_GetMonth(t *testing.T) {
  12. Convey("Test_GetMonth", t, func() {
  13. res, err := d.GetMonth(context.Background(), 11)
  14. So(err, ShouldBeNil)
  15. So(res, ShouldNotBeNil)
  16. })
  17. }
  18. func Test_MonthList(t *testing.T) {
  19. Convey("Test_MonthList", t, func() {
  20. res, err := d.MonthList(context.TODO())
  21. So(err, ShouldBeNil)
  22. So(res, ShouldNotBeEmpty)
  23. })
  24. }
  25. func Test_MonthEdit(t *testing.T) {
  26. var (
  27. id int64 = 31
  28. status int8 = 1
  29. op = "test"
  30. )
  31. Convey("Test_MonthEdit", t, func() {
  32. res, err := d.MonthEdit(context.Background(), id, status, op)
  33. So(err, ShouldBeNil)
  34. So(res, ShouldBeGreaterThanOrEqualTo, 0)
  35. })
  36. }
  37. func Test_GetPrice(t *testing.T) {
  38. var id int64 = 60
  39. Convey("Test_GetPrice", t, func() {
  40. res, err := d.GetPrice(context.Background(), id)
  41. So(err, ShouldBeNil)
  42. So(res, ShouldNotBeNil)
  43. })
  44. }
  45. func Test_MonthPriceList(t *testing.T) {
  46. Convey("Test_MonthPriceList", t, func() {
  47. var (
  48. err error
  49. eff int64
  50. res []*model.VipMonthPrice
  51. )
  52. ap := &model.VipMonthPrice{MonthID: 2, Money: 2.00}
  53. eff, err = d.PriceAdd(ctx, ap)
  54. So(err, ShouldBeNil)
  55. So(eff, ShouldEqual, 1)
  56. res, err = d.PriceList(context.TODO(), 2)
  57. So(err, ShouldBeNil)
  58. So(res, ShouldNotBeEmpty)
  59. })
  60. }
  61. func Test_PriceEdit(t *testing.T) {
  62. var (
  63. vp = &model.VipMonthPrice{MonthID: 2, Money: 2.00}
  64. )
  65. Convey("Test_PriceEdit", t, func() {
  66. res, err := d.PriceEdit(context.Background(), vp)
  67. So(err, ShouldBeNil)
  68. So(res, ShouldBeGreaterThanOrEqualTo, 0)
  69. })
  70. }