module_test.go 1.0 KB

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