redis_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package v2
  2. import (
  3. "context"
  4. "go-common/app/infra/config/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestV2Hosts(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. svr = "11133_fat1_sh001"
  12. )
  13. convey.Convey("Hosts", t, func(ctx convey.C) {
  14. hosts, err := d.Hosts(c, svr)
  15. ctx.Convey("Then err should be nil.hosts should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(hosts, convey.ShouldNotBeNil)
  18. })
  19. })
  20. }
  21. func TestV2SetHost(t *testing.T) {
  22. var (
  23. c = context.TODO()
  24. host = &model.Host{}
  25. svr = "11133_fat1_sh001"
  26. )
  27. convey.Convey("SetHost", t, func(ctx convey.C) {
  28. err := d.SetHost(c, host, svr)
  29. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. })
  32. })
  33. }
  34. func TestV2ClearHost(t *testing.T) {
  35. var (
  36. c = context.TODO()
  37. svr = "11133_fat1_sh001"
  38. )
  39. convey.Convey("ClearHost", t, func(ctx convey.C) {
  40. err := d.ClearHost(c, svr)
  41. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. }
  46. func TestV2pingRedis(t *testing.T) {
  47. var (
  48. c = context.TODO()
  49. )
  50. convey.Convey("pingRedis", t, func(ctx convey.C) {
  51. err := d.pingRedis(c)
  52. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. })
  55. })
  56. }