Skip to content

Commit

Permalink
test: update
Browse files Browse the repository at this point in the history
  • Loading branch information
daoshenzzg committed Sep 11, 2024
1 parent f4c11bb commit 51a76a4
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion remote/goredisv8adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGoRedisV8Adaptor_MGet(t *testing.T) {
func TestGoRedisV9Adaptor_MGet(t *testing.T) {
client := NewGoRedisV8Adaptor(newRdb())

if err := client.SetEX(context.Background(), "key1", "value1", time.Minute); err != nil {
Expand Down Expand Up @@ -47,6 +47,31 @@ func TestGoRedisV8Adaptor_MSet(t *testing.T) {
assert.Equal(t, map[string]any{"key1": "value1", "key2": "2"}, result)
}

func TestGoRedisV8Adaptor_Del(t *testing.T) {
client := NewGoRedisV8Adaptor(newRdb())
err := client.SetEX(context.Background(), "key1", "value1", time.Minute)
assert.Nil(t, err)
value, err := client.Get(context.Background(), "key1")
assert.Nil(t, err)
assert.Equal(t, "value1", value)
}

func TestGoRedisV8Adaptor_SetXxNx(t *testing.T) {
client := NewGoRedisV8Adaptor(newRdb())
_, err := client.SetXX(context.Background(), "key1", "value1", time.Minute)
assert.Nil(t, err)
_, err = client.Get(context.Background(), "key1")
assert.NotNil(t, err)
assert.Equal(t, err, client.Nil())

_, err = client.SetNX(context.Background(), "key1", "value1", time.Minute)
assert.Nil(t, err)
value, err := client.Get(context.Background(), "key1")
assert.Nil(t, err)
assert.Equal(t, "value1", value)

}

func newRdb() *redis.Client {
s, err := miniredis.Run()
if err != nil {
Expand Down

0 comments on commit 51a76a4

Please sign in to comment.