version_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package version
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "testing"
  6. "time"
  7. "go-common/app/interface/main/app-resource/conf"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. s *Service
  12. )
  13. func WithService(f func(s *Service)) func() {
  14. return func() {
  15. f(s)
  16. }
  17. }
  18. func init() {
  19. dir, _ := filepath.Abs("../../cmd/app-resource-test.toml")
  20. flag.Set("conf", dir)
  21. conf.Init()
  22. s = New(conf.Conf)
  23. time.Sleep(time.Second)
  24. }
  25. func TestVersion(t *testing.T) {
  26. Convey("get Version data", t, WithService(func(s *Service) {
  27. res, err := s.Version(1)
  28. So(res, ShouldNotBeEmpty)
  29. So(err, ShouldBeNil)
  30. }))
  31. }
  32. func TestVersionUpdate(t *testing.T) {
  33. Convey("get VersionUpdate data", t, WithService(func(s *Service) {
  34. res, err := s.VersionUpdate(1, 1, "", "", "", "", "")
  35. So(res, ShouldNotBeEmpty)
  36. So(err, ShouldBeNil)
  37. }))
  38. }
  39. func TestVersionSo(t *testing.T) {
  40. Convey("get VersionSo data", t, WithService(func(s *Service) {
  41. res, err := s.VersionSo(1, 1, 1, "", "")
  42. So(res, ShouldNotBeEmpty)
  43. So(err, ShouldBeNil)
  44. }))
  45. }
  46. func TestVersionRn(t *testing.T) {
  47. Convey("get VersionRn data", t, WithService(func(s *Service) {
  48. res, err := s.VersionRn("", "", "")
  49. So(res, ShouldNotBeEmpty)
  50. So(err, ShouldBeNil)
  51. }))
  52. }