Skip to content

Commit 2eed9db

Browse files
committed
feat: add FCall/FCallRo/FunctionKill command
Signed-off-by: monkey92t <[email protected]>
1 parent 5042035 commit 2eed9db

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

commands_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -3086,6 +3086,14 @@ var _ = Describe("Commands", func() {
30863086
})
30873087
})
30883088

3089+
It("FunctionKill", func() {
3090+
operationStringCmd(clientMock, func() *ExpectedString {
3091+
return clientMock.ExpectFunctionKill()
3092+
}, func() *redis.StringCmd {
3093+
return client.FunctionKill(ctx)
3094+
})
3095+
})
3096+
30893097
It("FunctionDump", func() {
30903098
operationStringCmd(clientMock, func() *ExpectedString {
30913099
return clientMock.ExpectFunctionDump()
@@ -3102,6 +3110,22 @@ var _ = Describe("Commands", func() {
31023110
})
31033111
})
31043112

3113+
It("FCall", func() {
3114+
operationCmdCmd(clientMock, func() *ExpectedCmd {
3115+
return clientMock.ExpectFCall("func-1", []string{"key1", "key2"}, "arg1", "arg2")
3116+
}, func() *redis.Cmd {
3117+
return client.FCall(ctx, "func-1", []string{"key1", "key2"}, "arg1", "arg2")
3118+
})
3119+
})
3120+
3121+
It("FCallRo", func() {
3122+
operationCmdCmd(clientMock, func() *ExpectedCmd {
3123+
return clientMock.ExpectFCallRo("func-1", []string{"key1", "key2"}, "arg1", "arg2")
3124+
}, func() *redis.Cmd {
3125+
return client.FCallRo(ctx, "func-1", []string{"key1", "key2"}, "arg1", "arg2")
3126+
})
3127+
})
3128+
31053129
// ------------------------------------------------------------------
31063130

31073131
It("ACLDryRun", func() {

expect.go

+3
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ type baseMock interface {
353353
ExpectFunctionFlush() *ExpectedString
354354
ExpectFunctionFlushAsync() *ExpectedString
355355
ExpectFunctionList(q redis.FunctionListQuery) *ExpectedFunctionList
356+
ExpectFunctionKill() *ExpectedString
356357
ExpectFunctionDump() *ExpectedString
357358
ExpectFunctionRestore(libDump string) *ExpectedString
359+
ExpectFCall(function string, keys []string, args ...interface{}) *ExpectedCmd
360+
ExpectFCallRo(function string, keys []string, args ...interface{}) *ExpectedCmd
358361

359362
ExpectACLDryRun(username string, command ...interface{}) *ExpectedString
360363
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/onsi/ginkgo v1.16.5
77
github.com/onsi/gomega v1.25.0
8-
github.com/redis/go-redis/v9 v9.0.3-0.20230329134406-9aba95a74fa2
8+
github.com/redis/go-redis/v9 v9.0.3
99
)
1010

1111
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
3838
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
3939
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
4040
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
41-
github.com/redis/go-redis/v9 v9.0.3-0.20230329134406-9aba95a74fa2 h1:3pTy4Z2GUTMRJBX2F+i7CvqyqQx10feStcprdzDzjFE=
42-
github.com/redis/go-redis/v9 v9.0.3-0.20230329134406-9aba95a74fa2/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
41+
github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k=
42+
github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
4343
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
4444
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
4545
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

mock.go

+21
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,13 @@ func (m *mock) ExpectFunctionList(q redis.FunctionListQuery) *ExpectedFunctionLi
26342634
return e
26352635
}
26362636

2637+
func (m *mock) ExpectFunctionKill() *ExpectedString {
2638+
e := &ExpectedString{}
2639+
e.cmd = m.factory.FunctionKill(m.ctx)
2640+
m.pushExpect(e)
2641+
return e
2642+
}
2643+
26372644
func (m *mock) ExpectFunctionDump() *ExpectedString {
26382645
e := &ExpectedString{}
26392646
e.cmd = m.factory.FunctionDump(m.ctx)
@@ -2648,6 +2655,20 @@ func (m *mock) ExpectFunctionRestore(libDump string) *ExpectedString {
26482655
return e
26492656
}
26502657

2658+
func (m *mock) ExpectFCall(function string, keys []string, args ...interface{}) *ExpectedCmd {
2659+
e := &ExpectedCmd{}
2660+
e.cmd = m.factory.FCall(m.ctx, function, keys, args...)
2661+
m.pushExpect(e)
2662+
return e
2663+
}
2664+
2665+
func (m *mock) ExpectFCallRo(function string, keys []string, args ...interface{}) *ExpectedCmd {
2666+
e := &ExpectedCmd{}
2667+
e.cmd = m.factory.FCallRo(m.ctx, function, keys, args...)
2668+
m.pushExpect(e)
2669+
return e
2670+
}
2671+
26512672
// ------------------------------------------------------------------------
26522673

26532674
func (m *mock) ExpectACLDryRun(username string, command ...interface{}) *ExpectedString {

0 commit comments

Comments
 (0)