dao_test.go 848 B

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