dao_test.go 712 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/tool/saga/conf"
  8. )
  9. var (
  10. d *Dao
  11. ctx = context.Background()
  12. )
  13. func TestMain(m *testing.M) {
  14. if os.Getenv("DEPLOY_ENV") != "" {
  15. flag.Set("app_id", "test.ep.saga")
  16. flag.Set("conf_token", "1d10044ab80b21d37ea67445f0475237")
  17. flag.Set("tree_id", "56733")
  18. flag.Set("conf_version", "docker-1")
  19. flag.Set("deploy_env", "fat")
  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/saga-test.toml")
  26. }
  27. flag.Parse()
  28. if err := conf.Init(); err != nil {
  29. panic(err)
  30. }
  31. d = New()
  32. defer d.Close()
  33. os.Exit(m.Run())
  34. }