From 99acb9afe73783a08664ced22bef6fd065e96a8c Mon Sep 17 00:00:00 2001 From: Yash Suresh Chandra Date: Sun, 1 Dec 2024 02:09:55 +0530 Subject: [PATCH] hexpire command added --- commands_test.go | 16 ++++++++++++---- expect.go | 1 + go.mod | 4 ++-- go.sum | 4 ++++ mock.go | 7 +++++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/commands_test.go b/commands_test.go index cbaf200..ec129ac 100644 --- a/commands_test.go +++ b/commands_test.go @@ -847,6 +847,14 @@ var _ = Describe("Commands", func() { }) }) + It("HExpire", func() { + operationIntSliceCmd(clientMock, func() *ExpectedIntSlice { + return clientMock.ExpectHExpire("key", 1*time.Minute, "field") + }, func() *redis.IntSliceCmd { + return client.HExpire(ctx, "key", 1*time.Minute, "field") + }) + }) + It("HGet", func() { operationStringCmd(clientMock, func() *ExpectedString { return clientMock.ExpectHGet("key", "field") @@ -3427,14 +3435,14 @@ var _ = Describe("Commands", func() { It("TSMGetWithArgs", func() { operationMapStringSliceInterfaceCmd(clientMock, func() *ExpectedMapStringSliceInterface { return clientMock.ExpectTSMGetWithArgs([]string{"filter"}, &redis.TSMGetOptions{ - Latest: true, - WithLabels: true, + Latest: true, + WithLabels: true, SelectedLabels: []interface{}{"label1", "label2", 100}, }) }, func() *redis.MapStringSliceInterfaceCmd { return client.TSMGetWithArgs(ctx, []string{"filter"}, &redis.TSMGetOptions{ - Latest: true, - WithLabels: true, + Latest: true, + WithLabels: true, SelectedLabels: []interface{}{"label1", "label2", 100}, }) }) diff --git a/expect.go b/expect.go index c7c5b97..43b65e2 100644 --- a/expect.go +++ b/expect.go @@ -116,6 +116,7 @@ type baseMock interface { ExpectHDel(key string, fields ...string) *ExpectedInt ExpectHExists(key, field string) *ExpectedBool + ExpectHExpire(key string, expiration time.Duration, fields ...string) *ExpectedIntSlice ExpectHGet(key, field string) *ExpectedString ExpectHGetAll(key string) *ExpectedMapStringString ExpectHIncrBy(key, field string, incr int64) *ExpectedInt diff --git a/go.mod b/go.mod index bbc013e..8966638 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.18 require ( github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.25.0 - github.com/redis/go-redis/v9 v9.2.0 + github.com/redis/go-redis/v9 v9.7.0 ) require ( - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/google/go-cmp v0.5.9 // indirect diff --git a/go.sum b/go.sum index 0151d92..7a883f9 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -42,6 +44,8 @@ github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= github.com/redis/go-redis/v9 v9.2.0 h1:zwMdX0A4eVzse46YN18QhuDiM4uf3JmkOB4VZrdt5uI= github.com/redis/go-redis/v9 v9.2.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= +github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/mock.go b/mock.go index 3c6a3b9..821b262 100644 --- a/mock.go +++ b/mock.go @@ -1035,6 +1035,13 @@ func (m *mock) ExpectHExists(key, field string) *ExpectedBool { return e } +func (m *mock) ExpectHExpire(key string, expiration time.Duration, fields ...string) *ExpectedIntSlice { + e := &ExpectedIntSlice{} + e.cmd = m.factory.HExpire(m.ctx, key, expiration, fields...) + m.pushExpect(e) + return e +} + func (m *mock) ExpectHGet(key, field string) *ExpectedString { e := &ExpectedString{} e.cmd = m.factory.HGet(m.ctx, key, field)