service_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "testing"
  6. "time"
  7. "go-common/app/admin/main/vip/conf"
  8. "go-common/app/admin/main/vip/model"
  9. "go-common/library/log"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. //once sync.Once
  14. s *Service
  15. c = context.TODO()
  16. )
  17. func init() {
  18. flag.Set("conf", "../cmd/vip-admin-test.toml")
  19. if err := conf.Init(); err != nil {
  20. panic(err)
  21. }
  22. log.Init(conf.Conf.Log)
  23. defer log.Close()
  24. s = New(conf.Conf)
  25. time.Sleep(time.Second)
  26. }
  27. func Test_ScanUserInfo(t *testing.T) {
  28. Convey("should return true err == nil", t, func() {
  29. })
  30. }
  31. func TestService_FrozenCode(t *testing.T) {
  32. Convey("frozenCode", t, func() {
  33. codeID := 12
  34. status := 1
  35. err := s.FrozenCode(context.TODO(), int64(codeID), int8(status))
  36. So(err, ShouldBeNil)
  37. })
  38. }
  39. func TestService_FrozenBatchCode(t *testing.T) {
  40. Convey("frozen batch code", t, func() {
  41. batchCodeID := 12
  42. status := 2
  43. err := s.FrozenBatchCode(context.TODO(), int64(batchCodeID), int8(status))
  44. So(err, ShouldBeNil)
  45. })
  46. }
  47. func TestService_BusinessInfo(t *testing.T) {
  48. Convey("businessInfo", t, func() {
  49. id := 12
  50. _, err := s.BusinessInfo(context.TODO(), id)
  51. So(err, ShouldBeNil)
  52. })
  53. }
  54. func TestService_AllVersion(t *testing.T) {
  55. Convey("version", t, func() {
  56. _, err := s.AllVersion(context.TODO())
  57. So(err, ShouldBeNil)
  58. })
  59. }
  60. func TestService_SelCode(t *testing.T) {
  61. Convey("sel code", t, func() {
  62. arg := new(model.ArgCode)
  63. arg.ID = 12
  64. cursor := 1
  65. ps := 20
  66. res, _, _, err := s.SelCode(context.TODO(), arg, "zhaozhihao", int64(cursor), ps)
  67. So(res, ShouldNotBeEmpty)
  68. So(err, ShouldBeNil)
  69. })
  70. }
  71. func TestService_VipInfo(t *testing.T) {
  72. Convey("vip info", t, func() {
  73. mid := 1233
  74. _, err := s.VipInfo(context.TODO(), int64(mid))
  75. So(err, ShouldBeNil)
  76. })
  77. }
  78. func TestService_BatchInfoOfPool(t *testing.T) {
  79. Convey("batchn info ", t, func() {
  80. poolID := 12
  81. _, err := s.BatchInfoOfPool(context.TODO(), poolID)
  82. So(err, ShouldBeNil)
  83. })
  84. }
  85. func TestService_BusinessList(t *testing.T) {
  86. Convey("business list", t, func() {
  87. res, _, err := s.BusinessList(context.TODO(), 1, 20, -1)
  88. So(res, ShouldNotBeNil)
  89. So(err, ShouldBeNil)
  90. })
  91. }