dao_test.go 780 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package mc
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "os"
  7. "testing"
  8. "go-common/app/admin/main/aegis/conf"
  9. )
  10. var (
  11. d *Dao
  12. ctx context.Context
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.archive.aegis-admin")
  17. flag.Set("conf_token", "cad913269be022e1eb8c45a8d5408d78")
  18. flag.Set("tree_id", "60977")
  19. flag.Set("conf_version", "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. } else {
  26. flag.Set("conf", "../../cmd/aegis-admin.toml")
  27. }
  28. flag.Parse()
  29. if err := conf.Init(); err != nil {
  30. panic(fmt.Sprintf("conf.Init() error(%v)", err))
  31. }
  32. d = New(conf.Conf)
  33. ctx = context.TODO()
  34. os.Exit(m.Run())
  35. }