dao_test.go 893 B

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