Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 22 - Added ExpectScanType to mock #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions expect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down