dao_test.go 781 B

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