dao_test.go 947 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package block
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/admin/main/member/conf"
  7. "go-common/library/cache/memcache"
  8. xsql "go-common/library/database/sql"
  9. bm "go-common/library/net/http/blademaster"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.account.member-admin")
  17. flag.Set("conf_token", "c18eac2285e4e4a75a8672139c30d464")
  18. flag.Set("tree_id", "2135")
  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/member-admin-test.toml")
  27. }
  28. flag.Parse()
  29. if err := conf.Init(); err != nil {
  30. panic(err)
  31. }
  32. hc := bm.NewClient(conf.Conf.HTTPClient.Read)
  33. d = New(conf.Conf, hc, memcache.NewPool(conf.Conf.BlockMemcache), xsql.NewMySQL(conf.Conf.BlockMySQL))
  34. os.Exit(m.Run())
  35. }