dao_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package ups
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/service/main/videoup/conf"
  6. "os"
  7. "testing"
  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") != "" {
  15. flag.Set("app_id", "main.archive.videoup-service")
  16. flag.Set("conf_token", "4b62721602981eb3635dba3b0d866ac5")
  17. flag.Set("tree_id", "2308")
  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. }
  25. flag.Parse()
  26. if err := conf.Init(); err != nil {
  27. panic(err)
  28. }
  29. d = New(conf.Conf)
  30. m.Run()
  31. os.Exit(0)
  32. }
  33. func TestUpPing(t *testing.T) {
  34. var (
  35. c = context.TODO()
  36. )
  37. convey.Convey("Ping", t, func(ctx convey.C) {
  38. err := d.Ping(c)
  39. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  40. ctx.So(err, convey.ShouldBeNil)
  41. })
  42. })
  43. }
  44. func TestGrayCheckUps(t *testing.T) {
  45. var (
  46. c = context.TODO()
  47. )
  48. convey.Convey("GrayCheckUps", t, func(ctx convey.C) {
  49. _, err := d.GrayCheckUps(c, 1)
  50. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. })
  53. })
  54. }
  55. func TestUpSpecial(t *testing.T) {
  56. var (
  57. c = context.TODO()
  58. )
  59. convey.Convey("upSpecial", t, func(ctx convey.C) {
  60. _, err := d.upSpecial(c, "1")
  61. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldBeNil)
  63. })
  64. })
  65. }