dao_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/library/conf/paladin"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. d *Dao
  12. )
  13. func TestMain(m *testing.M) {
  14. if os.Getenv("DEPLOY_ENV") == "uat" {
  15. flag.Set("app_id", "main.manager.workflow-admin")
  16. flag.Set("conf_token", "daebcaa3b1886d74e1b8f0361b34b04c")
  17. flag.Set("tree_id", "6812")
  18. flag.Set("conf_version", "docker-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. } else {
  25. flag.Set("region", "sh")
  26. flag.Set("zone", "sh001")
  27. flag.Set("app_id", "main.manager.workflow-admin")
  28. flag.Set("deploy.env", "dev")
  29. flag.Set("conf_token", "1de17252107b89394b5e72e07bfbc8de")
  30. flag.Set("conf_path", "/tmp")
  31. flag.Set("conf_version", "docker-1")
  32. flag.Set("conf_host", "config.bilibili.co")
  33. flag.Set("tree_id", "6812")
  34. }
  35. flag.Parse()
  36. if err := paladin.Init(); err != nil {
  37. panic(err)
  38. }
  39. d = New()
  40. os.Exit(m.Run())
  41. }
  42. func TestPing(t *testing.T) {
  43. convey.Convey("Ping", t, func() {
  44. d.Ping(context.TODO())
  45. })
  46. }