net_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package redis
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. var (
  8. kvs = map[string]string{
  9. "test:1": "test111-11",
  10. "test:2": "test222-22",
  11. }
  12. ks = []string{"test:1", "test:2"}
  13. )
  14. func TestRedisSetMulti(t *testing.T) {
  15. var (
  16. c = context.TODO()
  17. )
  18. convey.Convey("SetMulti", t, func(ctx convey.C) {
  19. err := d.SetMulti(c, kvs)
  20. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. }
  25. func TestRedisMGet(t *testing.T) {
  26. var (
  27. c = context.TODO()
  28. )
  29. convey.Convey("MGet", t, func(ctx convey.C) {
  30. dest, err := d.MGet(c, ks...)
  31. ctx.Convey("Then err should be nil.dest should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(dest, convey.ShouldNotBeNil)
  34. })
  35. })
  36. }
  37. func TestRedisDelMulti(t *testing.T) {
  38. var (
  39. c = context.TODO()
  40. )
  41. convey.Convey("DelMulti", t, func(ctx convey.C) {
  42. err := d.DelMulti(c, ks...)
  43. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. })
  46. })
  47. }