salary_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package service
  2. import (
  3. "testing"
  4. "time"
  5. "go-common/app/job/main/vip/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. // go test -test.v -test.run TestServiceSalaryCoupon
  9. func TestServiceSalaryCoupon(t *testing.T) {
  10. Convey("TestServiceSalaryCoupon", t, func() {
  11. var (
  12. err error
  13. mid int64 = 999
  14. st int8 = model.TimingSalaryType
  15. vt int8 = model.AnnualVip
  16. dv = time.Now().Format("2006_01")
  17. atonce = model.CouponSalaryTiming
  18. )
  19. err = s.salaryCoupon(c, mid, st, vt, dv, atonce)
  20. So(err, ShouldBeNil)
  21. })
  22. }
  23. // go test -test.v -test.run TestServiceSalaryInsertAct
  24. func TestServiceSalaryInsertAct(t *testing.T) {
  25. Convey("TestServiceSalaryCoupon", t, func() {
  26. var (
  27. err error
  28. nvip = &model.VipUserInfoMsg{
  29. Mid: 9995,
  30. Status: 1,
  31. OverdueTime: "2018-06-11 18:27:12",
  32. AnnualVipOverdueTime: "2018-06-09 18:27:12",
  33. }
  34. )
  35. err = s.salaryInsertAct(c, nvip)
  36. So(err, ShouldBeNil)
  37. nvip.Mid = 88881
  38. nvip.OverdueTime = "2018-07-31 18:27:12"
  39. nvip.AnnualVipOverdueTime = "2018-07-31 18:27:12"
  40. err = s.salaryInsertAct(c, nvip)
  41. So(err, ShouldBeNil)
  42. })
  43. }
  44. // go test -test.v -test.run TestServiceSalaryUpdateAct
  45. func TestServiceSalaryUpdateAct(t *testing.T) {
  46. Convey("TestServiceSalaryUpdateAct", t, func() {
  47. var (
  48. err error
  49. nvip = &model.VipUserInfoMsg{
  50. Mid: 65,
  51. Status: 2,
  52. OverdueTime: "2019-06-11 18:27:12",
  53. AnnualVipOverdueTime: "2019-06-11 18:27:12",
  54. }
  55. ovip = &model.VipUserInfoMsg{
  56. Mid: 65,
  57. Status: 2,
  58. OverdueTime: "2018-06-16 18:27:12",
  59. AnnualVipOverdueTime: "2018-06-09 18:27:12",
  60. Type: 1,
  61. }
  62. )
  63. // vip -> a vip
  64. err = s.salaryUpdateAct(c, nvip, ovip)
  65. So(err, ShouldBeNil)
  66. // not vip -> vip
  67. ovip.OverdueTime = "2017-06-11 18:27:12"
  68. nvip.OverdueTime = "2018-07-31 18:27:12"
  69. nvip.AnnualVipOverdueTime = "2018-07-31 18:27:12"
  70. ovip.Mid = 66
  71. nvip.Mid = 66
  72. err = s.salaryUpdateAct(c, nvip, ovip)
  73. So(err, ShouldBeNil)
  74. // vip - > a vip
  75. ovip.OverdueTime = "2018-08-19 18:27:12"
  76. nvip.AnnualVipOverdueTime = "2019-06-11 18:27:12"
  77. ovip.Mid = 66
  78. nvip.Mid = 66
  79. err = s.salaryUpdateAct(c, nvip, ovip)
  80. So(err, ShouldBeNil)
  81. nvip.Mid = 67
  82. err = s.salaryInsertAct(c, nvip)
  83. So(err, ShouldBeNil)
  84. })
  85. }
  86. // go test -test.v -test.run TestServiceScanSalaryLog
  87. func TestServiceScanSalaryLog(t *testing.T) {
  88. Convey("TestServiceScanSalaryLog", t, func() {
  89. err := s.ScanSalaryLog(c)
  90. So(err, ShouldBeNil)
  91. })
  92. }