dao_test.go 825 B

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