dao_test.go 797 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package dao
  2. import (
  3. "flag"
  4. "go-common/app/service/main/antispam/conf"
  5. "os"
  6. "testing"
  7. )
  8. var (
  9. d *Dao
  10. kwi *KeywordDaoImpl
  11. regdi *RegexpDaoImpl
  12. rdi *RuleDaoImpl
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.community.antispam-service")
  17. flag.Set("conf_token", "e0de72afaf4946ca836e9b7b459b833b")
  18. flag.Set("tree_id", "11041")
  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. }
  26. flag.Parse()
  27. if err := conf.Init(""); err != nil {
  28. panic(err)
  29. }
  30. Init(conf.Conf)
  31. d = New(conf.Conf)
  32. kwi = NewKeywordDao()
  33. regdi = NewRegexpDao()
  34. rdi = NewRuleDao()
  35. m.Run()
  36. os.Exit(0)
  37. }