dao_test.go 913 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package pgc
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "strings"
  7. "go-common/app/interface/main/tv/conf"
  8. "gopkg.in/h2non/gock.v1"
  9. )
  10. var (
  11. d *Dao
  12. ctx = context.Background()
  13. )
  14. func init() {
  15. // dir, _ := filepath.Abs("../../cmd/tv-interface.toml")
  16. // flag.Set("conf", dir)
  17. if os.Getenv("DEPLOY_ENV") != "" {
  18. flag.Set("app_id", "main.web-svr.tv-interface")
  19. flag.Set("conf_token", "07c1826c1f39df02a1411cdd6f455879")
  20. flag.Set("tree_id", "15326")
  21. flag.Set("conf_version", "docker-1")
  22. flag.Set("deploy_env", "uat")
  23. flag.Set("conf_host", "config.bilibili.co")
  24. flag.Set("conf_path", "/tmp")
  25. flag.Set("region", "sh")
  26. flag.Set("zone", "sh001")
  27. }
  28. flag.Parse()
  29. if err := conf.Init(); err != nil {
  30. panic(err)
  31. }
  32. d = New(conf.Conf)
  33. }
  34. func httpMock(method, url string) *gock.Request {
  35. r := gock.New(url)
  36. r.Method = strings.ToUpper(method)
  37. d.client.SetTransport(gock.DefaultTransport)
  38. return r
  39. }