dao_test.go 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package region
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-view/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func init() {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.app-svr.app-view")
  17. flag.Set("conf_token", "3a4CNLBhdFbRQPs7B4QftGvXHtJo92xw")
  18. flag.Set("tree_id", "4575")
  19. flag.Set("conf_version", "docker-1")
  20. flag.Set("deploy_env", "uat")
  21. flag.Set("conf_host", "config.bilibili.co")
  22. flag.Set("conf_path", "/tmp")
  23. flag.Set("region", "sh")
  24. flag.Set("zone", "sh001")
  25. }
  26. flag.Parse()
  27. if err := conf.Init(); err != nil {
  28. panic(err)
  29. }
  30. d = New(conf.Conf)
  31. time.Sleep(time.Second)
  32. }
  33. func ctx() context.Context {
  34. return context.Background()
  35. }
  36. func TestSeconds(t *testing.T) {
  37. Convey("get Seconds all", t, func() {
  38. res, err := d.Seconds(ctx())
  39. So(err, ShouldBeNil)
  40. So(res, ShouldNotBeEmpty)
  41. })
  42. }