dao_test.go 748 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package cms
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/job/main/tv/conf"
  7. "gopkg.in/h2non/gock.v1"
  8. )
  9. var d *Dao
  10. func TestMain(m *testing.M) {
  11. if os.Getenv("DEPLOY_ENV") != "" {
  12. flag.Set("app_id", "main.web-svr.tv-job")
  13. flag.Set("conf_token", "ab3e9801a77c076b997de0ac5cb21775")
  14. flag.Set("tree_id", "15260")
  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. flag.Set("conf", "../../cmd/tv-job-test.toml")
  23. }
  24. flag.Parse()
  25. if err := conf.Init(); err != nil {
  26. panic(err)
  27. }
  28. d = New(conf.Conf)
  29. d.client.SetTransport(gock.DefaultTransport)
  30. m.Run()
  31. os.Exit(0)
  32. }