Skip to content

Commit de2997b

Browse files
authored
Merge pull request #62 from monkey92t/new_cmd
feat: add ZAddLT,ZAddGT command
2 parents aaa7c80 + aef0699 commit de2997b

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

commands_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,34 @@ var _ = Describe("Commands", func() {
16751675
})
16761676
})
16771677

1678+
It("ZAddLT", func() {
1679+
operationIntCmd(clientMock, func() *ExpectedInt {
1680+
return clientMock.ExpectZAddLT("zset", redis.Z{
1681+
Member: "a",
1682+
Score: 1,
1683+
})
1684+
}, func() *redis.IntCmd {
1685+
return client.ZAddLT(ctx, "zset", redis.Z{
1686+
Member: "a",
1687+
Score: 1,
1688+
})
1689+
})
1690+
})
1691+
1692+
It("ZAddGT", func() {
1693+
operationIntCmd(clientMock, func() *ExpectedInt {
1694+
return clientMock.ExpectZAddGT("zset", redis.Z{
1695+
Member: "a",
1696+
Score: 1,
1697+
})
1698+
}, func() *redis.IntCmd {
1699+
return client.ZAddGT(ctx, "zset", redis.Z{
1700+
Member: "a",
1701+
Score: 1,
1702+
})
1703+
})
1704+
})
1705+
16781706
It("ZAddNX", func() {
16791707
operationIntCmd(clientMock, func() *ExpectedInt {
16801708
return clientMock.ExpectZAddNX("zset", redis.Z{

expect.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ type baseMock interface {
207207
ExpectBZMPop(timeout time.Duration, order string, count int64, keys ...string) *ExpectedZSliceWithKey
208208

209209
ExpectZAdd(key string, members ...redis.Z) *ExpectedInt
210+
ExpectZAddLT(key string, members ...redis.Z) *ExpectedInt
211+
ExpectZAddGT(key string, members ...redis.Z) *ExpectedInt
210212
ExpectZAddNX(key string, members ...redis.Z) *ExpectedInt
211213
ExpectZAddXX(key string, members ...redis.Z) *ExpectedInt
212214
ExpectZAddArgs(key string, args redis.ZAddArgs) *ExpectedInt

go.mod

Lines changed: 1 addition & 1 deletion
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.20230223112541-6045d2e4561c
8+
github.com/redis/go-redis/v9 v9.0.3-0.20230304070314-9664fd235954
99
)
1010

1111
require (

go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
33
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
44
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
55
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
76
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
87
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
98
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
@@ -38,13 +37,11 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
3837
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
3938
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
4039
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
41-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4240
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
43-
github.com/redis/go-redis/v9 v9.0.3-0.20230223112541-6045d2e4561c h1:HU8TAwucfDaYERowWS2hTe3GyMx46wOdg5iNnhZzZuY=
44-
github.com/redis/go-redis/v9 v9.0.3-0.20230223112541-6045d2e4561c/go.mod h1:6kjiKPy72LcR7xJX4bMLuf+2Rd/tpBFk4YKJTZ1jTNA=
41+
github.com/redis/go-redis/v9 v9.0.3-0.20230304070314-9664fd235954 h1:my7nLlAOlob02/9yr4GR0pStBXgQ3yGcaS/f5MxI24k=
42+
github.com/redis/go-redis/v9 v9.0.3-0.20230304070314-9664fd235954/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
4543
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
4644
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
47-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
4845
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
4946
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5047
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

mock.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,20 @@ func (m *mock) ExpectZAdd(key string, members ...redis.Z) *ExpectedInt {
16531653
return e
16541654
}
16551655

1656+
func (m *mock) ExpectZAddLT(key string, members ...redis.Z) *ExpectedInt {
1657+
e := &ExpectedInt{}
1658+
e.cmd = m.factory.ZAddLT(m.ctx, key, members...)
1659+
m.pushExpect(e)
1660+
return e
1661+
}
1662+
1663+
func (m *mock) ExpectZAddGT(key string, members ...redis.Z) *ExpectedInt {
1664+
e := &ExpectedInt{}
1665+
e.cmd = m.factory.ZAddGT(m.ctx, key, members...)
1666+
m.pushExpect(e)
1667+
return e
1668+
}
1669+
16561670
func (m *mock) ExpectZAddNX(key string, members ...redis.Z) *ExpectedInt {
16571671
e := &ExpectedInt{}
16581672
e.cmd = m.factory.ZAddNX(m.ctx, key, members...)

0 commit comments

Comments
 (0)