dao_test.go 827 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package dao
  2. import (
  3. "flag"
  4. "os"
  5. "testing"
  6. "go-common/app/service/main/share/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.app-svr.share-service")
  15. flag.Set("conf_token", "120ed94e23b963fc0564fbdb662916c3")
  16. flag.Set("tree_id", "25960")
  17. flag.Set("conf_version", "docker-1")
  18. flag.Set("deploy_env", "uat")
  19. flag.Set("conf_host", "config.bilibili.co")
  20. flag.Set("conf_path", "/tmp")
  21. flag.Set("region", "sh")
  22. flag.Set("zone", "sh001")
  23. } else {
  24. flag.Set("conf", "../cmd/share-service-test.toml")
  25. }
  26. flag.Parse()
  27. if err := conf.Init(); err != nil {
  28. panic(err)
  29. }
  30. d = New(conf.Conf)
  31. m.Run()
  32. os.Exit(0)
  33. }
  34. func TestPing(t *testing.T) {
  35. convey.Convey("Ping", t, func() {
  36. d.Ping()
  37. })
  38. }