unicom_test.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package unicom
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-wall/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. )
  14. func WithService(f func(s *Service)) func() {
  15. return func() {
  16. f(s)
  17. }
  18. }
  19. func init() {
  20. dir, _ := filepath.Abs("../../cmd/app-wall-test.toml")
  21. flag.Set("conf", dir)
  22. conf.Init()
  23. s = New(conf.Conf)
  24. time.Sleep(time.Second)
  25. }
  26. func TestUserFlow(t *testing.T) {
  27. Convey("Unicom UserFlow", t, WithService(func(s *Service) {
  28. res, _, err := s.UserFlow(context.TODO(), "", "iphone", "127.0.0.1", 111, time.Now())
  29. So(res, ShouldNotBeEmpty)
  30. So(err, ShouldBeNil)
  31. }))
  32. }
  33. func TestUserState(t *testing.T) {
  34. Convey("Unicom UserState", t, WithService(func(s *Service) {
  35. res, _, err := s.UserState(context.TODO(), "", "iphone", "127.0.0.1", 111, time.Now())
  36. So(res, ShouldNotBeEmpty)
  37. So(err, ShouldBeNil)
  38. }))
  39. }
  40. func TestUnicomState(t *testing.T) {
  41. Convey("Unicom UnicomState", t, WithService(func(s *Service) {
  42. res, err := s.UnicomState(context.TODO(), "", "iphone", "127.0.0.1", 111, time.Now())
  43. So(res, ShouldNotBeEmpty)
  44. So(err, ShouldBeNil)
  45. }))
  46. }
  47. func TestUserFlowState(t *testing.T) {
  48. Convey("Unicom UserFlowState", t, WithService(func(s *Service) {
  49. res, err := s.UserFlowState(context.TODO(), "", time.Now())
  50. So(res, ShouldNotBeEmpty)
  51. So(err, ShouldBeNil)
  52. }))
  53. }
  54. func TestIsUnciomIP(t *testing.T) {
  55. Convey("Unicom IsUnciomIP", t, WithService(func(s *Service) {
  56. err := s.IsUnciomIP(0, "127.0.0.1", "iphone", 0, time.Now())
  57. So(err, ShouldBeNil)
  58. }))
  59. }
  60. func TestUserUnciomIP(t *testing.T) {
  61. Convey("Unicom UserUnciomIP", t, WithService(func(s *Service) {
  62. err := s.UserUnciomIP(0, "127.0.0.1", "", "iphone", 0, time.Now())
  63. So(err, ShouldBeNil)
  64. }))
  65. }
  66. func TestOrder(t *testing.T) {
  67. Convey("Unicom Order", t, WithService(func(s *Service) {
  68. res, _, err := s.Order(context.TODO(), "", "", 0, time.Now())
  69. So(res, ShouldNotBeEmpty)
  70. So(err, ShouldBeNil)
  71. }))
  72. }
  73. func TestCancelOrder(t *testing.T) {
  74. Convey("Unicom CancelOrder", t, WithService(func(s *Service) {
  75. res, _, err := s.CancelOrder(context.TODO(), "")
  76. So(res, ShouldNotBeEmpty)
  77. So(err, ShouldBeNil)
  78. }))
  79. }
  80. func TestUnicomSMSCode(t *testing.T) {
  81. Convey("Unicom UnicomSMSCode", t, WithService(func(s *Service) {
  82. res, err := s.UnicomSMSCode(context.TODO(), "", time.Now())
  83. So(res, ShouldNotBeEmpty)
  84. So(err, ShouldBeNil)
  85. }))
  86. }
  87. func TestAddUnicomBind(t *testing.T) {
  88. Convey("Unicom AddUnicomBind", t, WithService(func(s *Service) {
  89. res, err := s.AddUnicomBind(context.TODO(), "", 1, 1, time.Now())
  90. So(res, ShouldNotBeEmpty)
  91. So(err, ShouldBeNil)
  92. }))
  93. }
  94. func TestReleaseUnicomBind(t *testing.T) {
  95. Convey("Unicom ReleaseUnicomBind", t, WithService(func(s *Service) {
  96. res, err := s.ReleaseUnicomBind(context.TODO(), 1, 1)
  97. So(res, ShouldNotBeEmpty)
  98. So(err, ShouldBeNil)
  99. }))
  100. }
  101. func TestUserBind(t *testing.T) {
  102. Convey("Unicom UserBind", t, WithService(func(s *Service) {
  103. res, _, err := s.UserBind(context.TODO(), 1)
  104. So(res, ShouldNotBeEmpty)
  105. So(err, ShouldBeNil)
  106. }))
  107. }
  108. func TestUnicomPackList(t *testing.T) {
  109. Convey("Unicom UnicomPackList", t, WithService(func(s *Service) {
  110. res := s.UnicomPackList()
  111. So(res, ShouldNotBeEmpty)
  112. }))
  113. }
  114. func TestUnicomPackReceive(t *testing.T) {
  115. Convey("Unicom UnicomPackReceive", t, WithService(func(s *Service) {
  116. res, _ := s.UnicomPackReceive(context.TODO(), 1, 1, time.Now())
  117. So(res, ShouldNotBeEmpty)
  118. }))
  119. }
  120. func TestUnicomUnicomFlowPack(t *testing.T) {
  121. Convey("Unicom UnicomFlowPack", t, WithService(func(s *Service) {
  122. res, _ := s.UnicomFlowPack(context.TODO(), 1, "", time.Now())
  123. So(res, ShouldNotBeEmpty)
  124. }))
  125. }
  126. func TestUnicomloadUnicomFlow(t *testing.T) {
  127. Convey("Unicom loadUnicomFlow", t, WithService(func(s *Service) {
  128. s.loadUnicomFlow()
  129. }))
  130. }
  131. func TestUnicomloadUnicomIPOrder(t *testing.T) {
  132. Convey("Unicom loadUnicomIPOrder", t, WithService(func(s *Service) {
  133. s.loadUnicomIPOrder(time.Now())
  134. }))
  135. }