dao_test.go 826 B

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