dao_test.go 706 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package dao
  2. import (
  3. "flag"
  4. "os"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/admin/main/open/conf"
  8. )
  9. var (
  10. d *Dao
  11. )
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "" {
  14. flag.Set("app_id", "")
  15. flag.Set("conf_token", "")
  16. flag.Set("tree_id", "")
  17. flag.Set("conf_version", "server-1")
  18. flag.Set("deploy_env", "uat")
  19. flag.Set("conf_host", "config.bilibili.co")
  20. flag.Set("conf_path", "/tmp")
  21. flag.Set("region", "sh")
  22. flag.Set("zone", "sh001")
  23. }
  24. flag.Parse()
  25. dir, _ := filepath.Abs("../cmd/open-admin-test.toml")
  26. if err := flag.Set("conf", dir); err != nil {
  27. panic(err)
  28. }
  29. if err := conf.Init(); err != nil {
  30. panic(err)
  31. }
  32. d = New(conf.Conf)
  33. m.Run()
  34. os.Exit(1)
  35. }