resouce_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/vip/model"
  7. xtime "go-common/library/time"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func Test_GrandResouce(t *testing.T) {
  11. Convey("should return true err == nil and failMids is empty", t, func() {
  12. var (
  13. mids []int
  14. remark = "系统备注"
  15. batchID = 5
  16. username = "system"
  17. )
  18. mids = append(mids, 110)
  19. failMids, err := s.GrandResouce(context.TODO(), remark, int64(batchID), mids, username)
  20. So(err, ShouldBeNil)
  21. So(failMids, ShouldBeEmpty)
  22. })
  23. }
  24. func TestService_BatchInfo(t *testing.T) {
  25. Convey("batch info", t, func() {
  26. id := 12
  27. _, err := s.BatchInfo(context.TODO(), id)
  28. So(err, ShouldBeNil)
  29. })
  30. }
  31. func TestService_PoolInfo(t *testing.T) {
  32. Convey("pool info", t, func() {
  33. id := 12
  34. _, err := s.PoolInfo(context.TODO(), id)
  35. So(err, ShouldBeNil)
  36. })
  37. }
  38. func Test_UpdateResouce(t *testing.T) {
  39. Convey("should ", t, func() {
  40. pojo := new(model.ResoucePoolBo)
  41. pojo.ID = 25
  42. pojo.PoolName = "test123123112311"
  43. pojo.BusinessID = 3
  44. pojo.Reason = "zhaozhihao"
  45. pojo.CodeExpireTime = xtime.Time(time.Now().Unix())
  46. pojo.StartTime = xtime.Time(time.Now().AddDate(0, 0, -1).Unix())
  47. pojo.EndTime = xtime.Time(time.Now().AddDate(0, 0, 10).Unix())
  48. pojo.Contacts = "阿斯顿发"
  49. pojo.ContactsNumber = "123124123"
  50. err := s.UpdatePool(context.TODO(), pojo)
  51. So(err, ShouldBeNil)
  52. })
  53. }
  54. func Test_SaveBatchCode(t *testing.T) {
  55. Convey("testing ", t, func() {
  56. arg := new(model.BatchCode)
  57. arg.ID = 26
  58. arg.PoolID = 25
  59. arg.Type = 1
  60. arg.BusinessID = 3
  61. arg.BatchName = "测试123"
  62. arg.SurplusCount = 100000
  63. arg.Count = 20000
  64. arg.Unit = 366
  65. arg.LimitDay = 9
  66. arg.MaxCount = 5
  67. arg.StartTime = xtime.Time(time.Now().Unix())
  68. arg.EndTime = xtime.Time(time.Now().AddDate(0, 0, 1).Unix())
  69. arg.Price = 10
  70. arg.Reason = "zhaozhihao"
  71. err := s.SaveBatchCode(context.TODO(), arg)
  72. So(err, ShouldBeNil)
  73. })
  74. }
  75. func Test_vipInfo(t *testing.T) {
  76. Convey("testing", t, func() {
  77. mid := 123
  78. res, err := s.VipInfo(context.TODO(), int64(mid))
  79. t.Logf("%+v", res)
  80. So(err, ShouldBeNil)
  81. })
  82. }
  83. func Test_drawback(t *testing.T) {
  84. Convey("drawback", t, func() {
  85. mid := 2089809
  86. username := "zhaozhihao"
  87. remark := "zhaozhihao"
  88. day := 10
  89. err := s.Drawback(context.TODO(), day, int64(mid), username, remark)
  90. So(err, ShouldBeNil)
  91. })
  92. }
  93. func TestService_ExportCode(t *testing.T) {
  94. Convey(" export code", t, func() {
  95. codes, err := s.ExportCode(context.TODO(), 13)
  96. So(codes, ShouldNotBeEmpty)
  97. So(err, ShouldBeNil)
  98. })
  99. }