dao_test.go 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package mcndao
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/interface/main/mcn/conf"
  7. "github.com/bluele/gcache"
  8. "go-common/app/interface/main/mcn/dao/global"
  9. )
  10. var (
  11. d *Dao
  12. localcache = gcache.New(1024).Simple().Build()
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.archive.mcn-interface")
  17. flag.Set("conf_token", "49e4671bafbf93059aeb602685052ca0")
  18. flag.Set("tree_id", "58909")
  19. flag.Set("conf_version", "docker-1")
  20. flag.Set("deploy_env", "uat")
  21. flag.Set("conf_host", "config.bilibili.co")
  22. flag.Set("conf_path", "/tmp")
  23. flag.Set("region", "sh")
  24. flag.Set("zone", "sh001")
  25. } else {
  26. flag.Set("conf", "../../cmd/mcn-interface.toml")
  27. }
  28. if os.Getenv("UT_LOCAL_TEST") != "" {
  29. flag.Set("conf", "../../cmd/mcn-interface.toml")
  30. }
  31. flag.Parse()
  32. if err := conf.Init(); err != nil {
  33. panic(err)
  34. }
  35. global.Init(conf.Conf)
  36. d = New(conf.Conf, localcache)
  37. os.Exit(m.Run())
  38. }