dao_test.go 886 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "flag"
  4. "go-common/app/service/main/identify-game/conf"
  5. "os"
  6. "testing"
  7. "gopkg.in/h2non/gock.v1"
  8. )
  9. var (
  10. d *Dao
  11. )
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "dev" {
  14. flag.Set("app_id", "main.account.identify-game")
  15. flag.Set("conf_token", "ba87634784874cad05e941bcabd55512")
  16. flag.Set("tree_id", "identify-game")
  17. flag.Set("tree_id", "11799")
  18. flag.Set("conf_version", "server-1")
  19. flag.Set("deploy_env", "uat")
  20. flag.Set("conf_host", "config.bilibili.co")
  21. flag.Set("conf_path", "/tmp")
  22. flag.Set("region", "sh")
  23. flag.Set("zone", "sh001")
  24. }
  25. flag.Parse()
  26. if err := conf.Init(); err != nil {
  27. panic(err)
  28. }
  29. d = New(conf.Conf)
  30. d.client.SetTransport(gock.DefaultTransport)
  31. m.Run()
  32. os.Exit(0)
  33. }
  34. //func httpMock(method, url string) *gock.Request {
  35. // r := gock.New(url)
  36. // r.Method = strings.ToUpper(method)
  37. // return r
  38. //}