service_test.go 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package service
  2. import (
  3. "flag"
  4. "go-common/app/admin/main/answer/conf"
  5. "os"
  6. "testing"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. var (
  10. s *Service
  11. )
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "" {
  14. flag.Set("app_id", "main.account-law.answer-admin")
  15. flag.Set("conf_appid", "main.account-law.answer-admin")
  16. flag.Set("conf_token", "bec0ecd7a2799a424602f9a0daea070d")
  17. flag.Set("tree_id", "4752")
  18. flag.Set("conf_version", "docker-1")
  19. flag.Set("deploy_env", "uat")
  20. flag.Set("conf_env", "10")
  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/answer-admin-test.toml")
  27. }
  28. flag.Parse()
  29. if err := conf.Init(); err != nil {
  30. panic(err)
  31. }
  32. s = New(conf.Conf)
  33. os.Exit(m.Run())
  34. }
  35. func TestServiceClose(t *testing.T) {
  36. convey.Convey("Close", t, func() {
  37. s.Close()
  38. })
  39. }