service_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "testing"
  6. "time"
  7. "go-common/app/job/main/vip/conf"
  8. "go-common/app/job/main/vip/model"
  9. "go-common/library/log"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. c context.Context
  15. )
  16. func init() {
  17. flag.Set("conf", "../cmd/vip-job-test.toml")
  18. if err := conf.Init(); err != nil {
  19. panic(err)
  20. }
  21. c = context.TODO()
  22. log.Init(conf.Conf.Xlog)
  23. defer log.Close()
  24. s = New(conf.Conf)
  25. time.Sleep(time.Second * 2)
  26. }
  27. func Test_ScanUserInfo(t *testing.T) {
  28. Convey("should return true err == nil", t, func() {
  29. err := s.ScanUserInfo(context.TODO())
  30. So(err, ShouldBeNil)
  31. })
  32. }
  33. func TestService_HadExpiredMsgJob(t *testing.T) {
  34. Convey("had expireMsg job", t, func() {
  35. s.hadExpiredMsgJob()
  36. })
  37. }
  38. func TestService_WillExpiredMsgJob(t *testing.T) {
  39. Convey("had expire msg job", t, func() {
  40. s.willExpiredMsgJob()
  41. })
  42. }
  43. func TestService_SendMessageJob(t *testing.T) {
  44. Convey("send message job", t, func() {
  45. s.sendMessageJob()
  46. })
  47. }
  48. func TestService_SendBcoinJob(t *testing.T) {
  49. Convey("send bcoin job", t, func() {
  50. s.sendBcoinJob()
  51. })
  52. }
  53. func TestSalaryVideoCouponJob(t *testing.T) {
  54. Convey("salaryVideoCouponJob err == nil", t, func() {
  55. s.salaryVideoCouponJob()
  56. s.salaryVideoCouponJob()
  57. })
  58. }
  59. func TestService_HandlerVipChangeHistory(t *testing.T) {
  60. Convey("handlervip change history ", t, func() {
  61. err := s.HandlerVipChangeHistory()
  62. So(err, ShouldBeNil)
  63. })
  64. }
  65. func TestService_HandlerBcoin(t *testing.T) {
  66. Convey(" handler bcoin history ", t, func() {
  67. err := s.HandlerBcoin()
  68. So(err, ShouldBeNil)
  69. })
  70. }
  71. func TestService_HandlerPayOrder(t *testing.T) {
  72. Convey("handler pay order", t, func() {
  73. err := s.HandlerPayOrder()
  74. So(err, ShouldBeNil)
  75. })
  76. }
  77. func Test_push(t *testing.T) {
  78. Convey("handler push data err should be nil", t, func() {
  79. err := s.pushData(context.TODO())
  80. So(err, ShouldBeNil)
  81. })
  82. }
  83. func TestService_CheckBcoinData(t *testing.T) {
  84. Convey("check bcoin data", t, func() {
  85. mids, err := s.CheckBcoinData(context.TODO())
  86. So(mids, ShouldBeEmpty)
  87. So(err, ShouldBeNil)
  88. })
  89. }
  90. func TestService_CheckChangeHistory(t *testing.T) {
  91. Convey("check change history", t, func() {
  92. mids, err := s.CheckChangeHistory(context.TODO())
  93. So(mids, ShouldBeEmpty)
  94. So(err, ShouldBeNil)
  95. })
  96. }
  97. func Test_HandlerAutoRenewLogInfo(t *testing.T) {
  98. Convey("err should be nil", t, func() {
  99. err := s.handlerAutoRenewLogInfo(context.TODO(), &model.VipUserInfo{Mid: 2089809, PayType: model.AutoRenew, PayChannelID: 100})
  100. So(err, ShouldBeNil)
  101. })
  102. }