dao_test.go 807 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package task
  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 TestMain(m *testing.M) {
  10. if os.Getenv("DEPLOY_ENV") != "" {
  11. flag.Set("app_id", "main.archive.videoup-admin")
  12. flag.Set("conf_token", "gRSfeavV7kJdY9875Gf29pbd2wrdKZ1a")
  13. flag.Set("tree_id", "2307")
  14. flag.Set("conf_version", "docker-1")
  15. flag.Set("deploy_env", "uat")
  16. flag.Set("conf_host", "config.bilibili.co")
  17. flag.Set("conf_path", "/tmp")
  18. flag.Set("region", "sh")
  19. flag.Set("zone", "sh001")
  20. } else {
  21. flag.Set("conf", "../../cmd/videoup-admin.toml")
  22. }
  23. flag.Parse()
  24. if err := conf.Init(); err != nil {
  25. panic(err)
  26. }
  27. d = New(conf.Conf)
  28. os.Exit(m.Run())
  29. }
  30. func WithDao(f func(d *Dao)) func() {
  31. return func() {
  32. Reset(func() {})
  33. f(d)
  34. }
  35. }