Skip to content

Commit 95faa68

Browse files
committed
feat: add Expiretime and PExpireTime cmd
Signed-off-by: monkey92t <golang@88.com>
1 parent 3961820 commit 95faa68

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

commands_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ var _ = Describe("Commands", func() {
163163
})
164164
})
165165

166+
It("ExpireTime", func() {
167+
operationDurationCmd(clientMock, func() *ExpectedDuration {
168+
return clientMock.ExpectExpireTime("key")
169+
}, func() *redis.DurationCmd {
170+
return client.ExpireTime(ctx, "key")
171+
})
172+
})
173+
166174
It("ExpireNX", func() {
167175
operationBoolCmd(clientMock, func() *ExpectedBool {
168176
return clientMock.ExpectExpireNX("key", 2*time.Second)
@@ -268,6 +276,14 @@ var _ = Describe("Commands", func() {
268276
})
269277
})
270278

279+
It("PExpireTime", func() {
280+
operationDurationCmd(clientMock, func() *ExpectedDuration {
281+
return clientMock.ExpectPExpireTime("key")
282+
}, func() *redis.DurationCmd {
283+
return client.PExpireTime(ctx, "key")
284+
})
285+
})
286+
271287
It("PTTL", func() {
272288
operationDurationCmd(clientMock, func() *ExpectedDuration {
273289
return clientMock.ExpectPTTL("key")

expect.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type baseMock interface {
3939
ExpectExists(keys ...string) *ExpectedInt
4040
ExpectExpire(key string, expiration time.Duration) *ExpectedBool
4141
ExpectExpireAt(key string, tm time.Time) *ExpectedBool
42+
ExpectExpireTime(key string) *ExpectedDuration
4243
ExpectExpireNX(key string, expiration time.Duration) *ExpectedBool
4344
ExpectExpireXX(key string, expiration time.Duration) *ExpectedBool
4445
ExpectExpireGT(key string, expiration time.Duration) *ExpectedBool
@@ -52,6 +53,7 @@ type baseMock interface {
5253
ExpectPersist(key string) *ExpectedBool
5354
ExpectPExpire(key string, expiration time.Duration) *ExpectedBool
5455
ExpectPExpireAt(key string, tm time.Time) *ExpectedBool
56+
ExpectPExpireTime(key string) *ExpectedDuration
5557
ExpectPTTL(key string) *ExpectedDuration
5658
ExpectRandomKey() *ExpectedString
5759
ExpectRename(key, newkey string) *ExpectedStatus

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.2
8+
github.com/redis/go-redis/v9 v9.0.3-0.20230207104127-9d5e48507ef3
99
)
1010

1111
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ github.com/redis/go-redis/v9 v9.0.1 h1:L1B0L2Y7dQMnKxwfzSwemceGlQwVUsqJ1kjkdaoNh
4646
github.com/redis/go-redis/v9 v9.0.1/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
4747
github.com/redis/go-redis/v9 v9.0.2 h1:BA426Zqe/7r56kCcvxYLWe1mkaz71LKF77GwgFzSxfE=
4848
github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
49+
github.com/redis/go-redis/v9 v9.0.3-0.20230207104127-9d5e48507ef3 h1:kyVjUJXiL4ucwG4wEw/JcvSUOeG4foJO1c1J0GecWo0=
50+
github.com/redis/go-redis/v9 v9.0.3-0.20230207104127-9d5e48507ef3/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
4951
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5052
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
5153
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=

mock.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,13 @@ func (m *mock) ExpectExpireAt(key string, tm time.Time) *ExpectedBool {
529529
return e
530530
}
531531

532+
func (m *mock) ExpectExpireTime(key string) *ExpectedDuration {
533+
e := &ExpectedDuration{}
534+
e.cmd = m.factory.ExpireTime(m.ctx, key)
535+
m.pushExpect(e)
536+
return e
537+
}
538+
532539
func (m *mock) ExpectExpireNX(key string, expiration time.Duration) *ExpectedBool {
533540
e := &ExpectedBool{}
534541
e.cmd = m.factory.ExpireNX(m.ctx, key, expiration)
@@ -620,6 +627,13 @@ func (m *mock) ExpectPExpireAt(key string, tm time.Time) *ExpectedBool {
620627
return e
621628
}
622629

630+
func (m *mock) ExpectPExpireTime(key string) *ExpectedDuration {
631+
e := &ExpectedDuration{}
632+
e.cmd = m.factory.PExpireTime(m.ctx, key)
633+
m.pushExpect(e)
634+
return e
635+
}
636+
623637
func (m *mock) ExpectPTTL(key string) *ExpectedDuration {
624638
e := &ExpectedDuration{}
625639
e.cmd = m.factory.PTTL(m.ctx, key)

0 commit comments

Comments
 (0)