dao_test.go 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/service/main/vipinfo/conf"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. d *Dao
  12. _testMid int64 = 1540883324
  13. _testMids = []int64{1540883324, 1540883325, 1540883326}
  14. )
  15. func TestMain(m *testing.M) {
  16. if os.Getenv("DEPLOY_ENV") != "" {
  17. flag.Set("app_id", "main.account.vipinfo")
  18. flag.Set("conf_token", "36fc5030a1e70fcac07edce2e941c506")
  19. flag.Set("tree_id", "66732")
  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/test.toml")
  28. }
  29. flag.Parse()
  30. if err := conf.Init(); err != nil {
  31. panic(err)
  32. }
  33. d = New(conf.Conf)
  34. code := m.Run()
  35. d.Close()
  36. os.Exit(code)
  37. }
  38. func TestDaoPing(t *testing.T) {
  39. convey.Convey("Ping", t, func(ctx convey.C) {
  40. err := d.Ping(context.Background())
  41. ctx.So(err, convey.ShouldBeNil)
  42. })
  43. }