allowance_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package service
  2. import (
  3. "go-common/app/admin/main/coupon/model"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. // go test -test.v -test.run TestAddAllowanceBatchInfo
  9. func TestAddAllowanceBatchInfo(t *testing.T) {
  10. Convey("TestAddAllowanceBatchInfo ", t, func() {
  11. var err error
  12. b := &model.CouponBatchInfo{
  13. AppID: 1,
  14. Name: "test1",
  15. MaxCount: 1000,
  16. CurrentCount: 1000,
  17. StartTime: 1532057501,
  18. ExpireTime: 1542057501,
  19. Ver: 1,
  20. Operator: "yubaihai",
  21. LimitCount: 20,
  22. FullAmount: 100,
  23. Amount: 20,
  24. State: 0,
  25. CouponType: 3,
  26. ExpireDay: 7,
  27. PlatformLimit: "3,4",
  28. }
  29. _, err = s.AddAllowanceBatchInfo(c, b)
  30. So(err, ShouldBeNil)
  31. })
  32. }
  33. // go test -test.v -test.run TestUpdateAllowanceBatchInfo
  34. func TestUpdateAllowanceBatchInfo(t *testing.T) {
  35. Convey("TestUpdateAllowanceBatchInfo ", t, func() {
  36. var err error
  37. b := &model.CouponBatchInfo{
  38. ID: 2,
  39. AppID: 1,
  40. Name: "test2",
  41. MaxCount: 10000,
  42. CurrentCount: 1000,
  43. StartTime: 1532057501,
  44. ExpireTime: 1542057501,
  45. Ver: 1,
  46. Operator: "yubaihai",
  47. LimitCount: 200,
  48. FullAmount: 100,
  49. Amount: 20,
  50. State: 0,
  51. CouponType: 3,
  52. PlatformLimit: "3",
  53. }
  54. err = s.UpdateAllowanceBatchInfo(c, b)
  55. So(err, ShouldBeNil)
  56. })
  57. }
  58. // go test -test.v -test.run TestUpdateBatchStatus
  59. func TestUpdateBatchStatus(t *testing.T) {
  60. Convey("TestUpdateBatchStatus ", t, func() {
  61. So(s.UpdateBatchStatus(c, model.BatchStateNormal, "yubaihai", 150), ShouldBeNil)
  62. })
  63. }
  64. // go test -test.v -test.run TestBatchInfo
  65. func TestBatchInfo(t *testing.T) {
  66. Convey("TestBatchInfo ", t, func() {
  67. res, err := s.BatchInfo(c, "test2")
  68. t.Logf("res(%v)", res)
  69. So(err, ShouldBeNil)
  70. })
  71. }
  72. // go test -test.v -test.run TestAllowanceSalary
  73. func TestAllowanceSalary(t *testing.T) {
  74. Convey("TestAllowanceSalary ", t, func() {
  75. count, err := s.AllowanceSalary(c, nil, nil, []int64{332}, "allowance_test1", "vip")
  76. time.Sleep(time.Second * 1)
  77. t.Logf("count(%v)", count)
  78. So(err, ShouldBeNil)
  79. })
  80. }
  81. // go test -test.v -test.run TestUpdateAllowanceState
  82. func TestUpdateAllowanceState(t *testing.T) {
  83. Convey("TestUpdateAllowanceState ", t, func() {
  84. err := s.UpdateAllowanceState(c, 1, model.NotUsed, "097060140820180713120943")
  85. So(err, ShouldBeNil)
  86. })
  87. }
  88. // go test -test.v -test.run TestAllowanceList
  89. func TestAllowanceList(t *testing.T) {
  90. Convey("TestAllowanceList", t, func() {
  91. res, err := s.AllowanceList(c, &model.ArgAllowanceSearch{
  92. Mid: 1,
  93. AppID: 0,
  94. })
  95. t.Logf("count(%v)", len(res))
  96. So(err, ShouldBeNil)
  97. })
  98. }