dao_test.go 811 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package databus
  2. import (
  3. "flag"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/main/videoup/conf"
  6. "os"
  7. "testing"
  8. )
  9. func WithDao(f func(d *Dao)) func() {
  10. return func() {
  11. Reset(func() {})
  12. f(d)
  13. }
  14. }
  15. func TestMain(m *testing.M) {
  16. if os.Getenv("DEPLOY_ENV") != "" {
  17. flag.Set("app_id", "main.archive.videoup-admin")
  18. flag.Set("conf_token", "gRSfeavV7kJdY9875Gf29pbd2wrdKZ1a")
  19. flag.Set("tree_id", "2307")
  20. flag.Set("conf_version", "docker-1")
  21. flag.Set("deploy_env", "uat")
  22. flag.Set("conf_host", "config.bilibili.co")
  23. flag.Set("conf_path", "/tmp")
  24. flag.Set("region", "sh")
  25. flag.Set("zone", "sh001")
  26. } else {
  27. flag.Set("conf", "../../cmd/videoup-admin.toml")
  28. }
  29. flag.Parse()
  30. if err := conf.Init(); err != nil {
  31. panic(err)
  32. }
  33. d = New(conf.Conf)
  34. os.Exit(m.Run())
  35. }