static_test.go 845 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package static
  2. import (
  3. "encoding/json"
  4. "flag"
  5. "fmt"
  6. "go-common/app/interface/main/app-resource/conf"
  7. "path/filepath"
  8. "testing"
  9. "time"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func WithService(f func(s *Service)) func() {
  16. return func() {
  17. f(s)
  18. }
  19. }
  20. func init() {
  21. dir, _ := filepath.Abs("../../cmd/app-resource-test.toml")
  22. flag.Set("conf", dir)
  23. conf.Init()
  24. s = New(conf.Conf)
  25. time.Sleep(time.Second)
  26. }
  27. // go test -conf="../../cmd/app-resource-test.toml" -v -test.run TestStatic
  28. func TestStatic(t *testing.T) {
  29. Convey("get static data", t, WithService(func(s *Service) {
  30. res, ver, err := s.Static(1, 22222, "", time.Now())
  31. result, err := json.Marshal(res)
  32. fmt.Printf("test static (%v) \n", string(result))
  33. So(res, ShouldNotBeEmpty)
  34. So(ver, ShouldNotBeEmpty)
  35. So(err, ShouldBeNil)
  36. }))
  37. }