dao_test.go 780 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package data
  2. import (
  3. "flag"
  4. "go-common/app/service/main/up/conf"
  5. "os"
  6. "testing"
  7. "go-common/app/service/main/up/dao"
  8. )
  9. var (
  10. d *Dao
  11. )
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "" {
  14. flag.Set("app_id", dao.AppID)
  15. flag.Set("conf_token", dao.UatToken)
  16. flag.Set("tree_id", dao.TreeID)
  17. flag.Set("conf_version", "docker-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. } else {
  24. flag.Set("conf", "../../cmd/up-service.toml")
  25. }
  26. if os.Getenv("UT_LOCAL_TEST") != "" {
  27. flag.Set("conf", "../../cmd/up-service.toml")
  28. }
  29. flag.Parse()
  30. if err := conf.Init(); err != nil {
  31. panic(err)
  32. }
  33. d = New(conf.Conf)
  34. m.Run()
  35. os.Exit(0)
  36. }