mobile_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package mobile
  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 TestActivation(t *testing.T) {
  27. Convey("Unicom Activation", t, WithService(func(s *Service) {
  28. res, err := s.Activation(context.TODO(), "", time.Now())
  29. So(res, ShouldNotBeEmpty)
  30. So(err, ShouldBeNil)
  31. }))
  32. }
  33. func TestMobileState(t *testing.T) {
  34. Convey("Unicom MobileState", t, WithService(func(s *Service) {
  35. res := s.MobileState(context.TODO(), "", time.Now())
  36. So(res, ShouldNotBeEmpty)
  37. }))
  38. }
  39. func TestUserMobileState(t *testing.T) {
  40. Convey("Unicom UserMobileState", t, WithService(func(s *Service) {
  41. res := s.UserMobileState(context.TODO(), "", time.Now())
  42. So(res, ShouldNotBeEmpty)
  43. }))
  44. }
  45. func TestIsMobileIP(t *testing.T) {
  46. Convey("Unicom IsMobileIP", t, WithService(func(s *Service) {
  47. res := s.IsMobileIP(1, "", "")
  48. So(res, ShouldNotBeEmpty)
  49. }))
  50. }