dao_test.go 961 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/service/main/ugcpay/conf"
  6. "os"
  7. "testing"
  8. )
  9. var (
  10. d *Dao
  11. )
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "" {
  14. flag.Set("app_id", "main.account.ugcpay-service")
  15. flag.Set("conf_token", "a3e98fbfb0f63520a8cdc699365460c2")
  16. flag.Set("tree_id", "62221")
  17. flag.Set("conf_version", "docker-1")
  18. flag.Set("deploy_env", "uat")
  19. flag.Set("conf_host", "config.bilibili.co")
  20. flag.Set("conf_path", "/tmp")
  21. flag.Set("region", "sh")
  22. flag.Set("zone", "sh001")
  23. } else {
  24. flag.Set("conf", "../cmd/test.toml")
  25. }
  26. flag.Parse()
  27. if err := conf.Init(); err != nil {
  28. panic(err)
  29. }
  30. d = New(conf.Conf)
  31. conf.Conf.CacheTTL.OrderTTL = 1
  32. conf.Conf.CacheTTL.AssetTTL = 1
  33. conf.Conf.CacheTTL.AssetRelationTTL = 1
  34. conf.Conf.CacheTTL.AggrIncomeUserTTL = 1
  35. conf.Conf.CacheTTL.AggrIncomeUserMonthlyTTL = 1
  36. if err := d.Ping(context.Background()); err != nil {
  37. panic(err)
  38. }
  39. os.Exit(m.Run())
  40. }