From 5a8cccd6ae8d7a215677372b4d360c04c8e40ba5 Mon Sep 17 00:00:00 2001 From: james-coopstools Date: Thu, 7 Apr 2022 13:04:02 -0400 Subject: [PATCH] Added ExcetScanType to mock --- client_test.go | 8 ++++++++ expect.go | 4 ++-- mock.go | 10 ++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/client_test.go b/client_test.go index a506486..402ac5a 100644 --- a/client_test.go +++ b/client_test.go @@ -922,6 +922,14 @@ var _ = Describe("RedisMock", func() { }) }) + It("ScanType", func() { + operationScanCmd(clientMock, func() *ExpectedScan { + return clientMock.ExpectScanType(0, "match", 2, "type") + }, func() *redis.ScanCmd { + return client.ScanType(ctx, 0, "match", 2, "type") + }) + }) + It("SScan", func() { operationScanCmd(clientMock, func() *ExpectedScan { return clientMock.ExpectSScan("key", 1, "match", 2) diff --git a/expect.go b/expect.go index af81a47..9eed90f 100644 --- a/expect.go +++ b/expect.go @@ -2,12 +2,11 @@ package redismock import ( "fmt" + "github.com/go-redis/redis/v8" "reflect" "sync" "time" "unsafe" - - "github.com/go-redis/redis/v8" ) type baseMock interface { @@ -89,6 +88,7 @@ type baseMock interface { ExpectBitField(key string, args ...interface{}) *ExpectedIntSlice ExpectScan(cursor uint64, match string, count int64) *ExpectedScan + ExpectScanType(cursor uint64, match string, count int64, keyType string) *ExpectedScan ExpectSScan(key string, cursor uint64, match string, count int64) *ExpectedScan ExpectHScan(key string, cursor uint64, match string, count int64) *ExpectedScan ExpectZScan(key string, cursor uint64, match string, count int64) *ExpectedScan diff --git a/mock.go b/mock.go index cf6e351..f925ce2 100644 --- a/mock.go +++ b/mock.go @@ -4,12 +4,11 @@ import ( "context" "errors" "fmt" + "github.com/go-redis/redis/v8" "reflect" "regexp" "strings" "time" - - "github.com/go-redis/redis/v8" ) type mock struct { @@ -828,6 +827,13 @@ func (m *mock) ExpectScan(cursor uint64, match string, count int64) *ExpectedSca return e } +func (m *mock) ExpectScanType(cursor uint64, match string, count int64, keyType string) *ExpectedScan { + e := &ExpectedScan{} + e.cmd = m.factory.ScanType(m.ctx, cursor, match, count, keyType) + m.pushExpect(e) + return e +} + func (m *mock) ExpectSScan(key string, cursor uint64, match string, count int64) *ExpectedScan { e := &ExpectedScan{} e.cmd = m.factory.SScan(m.ctx, key, cursor, match, count)