dao_test.go 1011 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package dao
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/admin/main/answer/conf"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. var (
  10. d *Dao
  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. d = New(conf.Conf)
  33. os.Exit(m.Run())
  34. }
  35. func TestNew(t *testing.T) {
  36. Convey("Close", t, func() {
  37. New(conf.Conf)
  38. })
  39. }
  40. func TestClose(t *testing.T) {
  41. Convey("Close", t, func() {
  42. d.Close()
  43. d = New(conf.Conf)
  44. })
  45. }