1
0
mirror of https://github.com/redis/go-redis.git synced 2025-04-16 09:23:06 +03:00

Initial testing

This commit is contained in:
ofekshenawa 2024-09-20 16:13:13 +03:00
parent 233f97accd
commit 711143687c
3 changed files with 55 additions and 2 deletions

2
go.mod
View File

@ -10,6 +10,6 @@ require (
)
retract (
v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead.
v9.5.4 // This version was accidentally released. Please use version 9.6.0 instead.
v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead.
)

View File

@ -431,7 +431,7 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
return false, err
}
}
panic(cmd.firstKeyPos())
retryTimeout := uint32(0)
if err := c.withConn(ctx, func(ctx context.Context, cn *pool.Conn) error {
if err := cn.WithWriter(c.context(ctx), c.opt.WriteTimeout, func(wr *proto.Writer) error {

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net"
"strconv"
"testing"
"time"
@ -633,3 +634,55 @@ var _ = Describe("Hook with MinIdleConns", func() {
}))
})
})
var _ = Describe("Command Name", func() {
var client *redis.Client
BeforeEach(func() {
client = redis.NewClient(redisOptions())
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
})
AfterEach(func() {
err := client.Close()
Expect(err).NotTo(HaveOccurred())
})
It("should return key name", func() {
mSet := client.MSet(ctx, "key1", "hello1", "key2", "hello2")
Expect(mSet.Err()).NotTo(HaveOccurred())
Expect(mSet.Val()).To(Equal("OK"))
Expect(mSet.Args()).To(Equal([]string{"MSET", "key1", "hello1", "key2", "hello2"}))
mGet := client.MGet(ctx, "key1", "key2", "_")
Expect(mGet.Err()).NotTo(HaveOccurred())
Expect(mGet.Val()).To(Equal([]interface{}{"hello1", "hello2", nil}))
// MSet struct
type set struct {
Set1 string `redis:"set1"`
Set2 int16 `redis:"set2"`
Set3 time.Duration `redis:"set3"`
Set4 interface{} `redis:"set4"`
Set5 map[string]interface{} `redis:"-"`
}
mSet = client.MSet(ctx, &set{
Set1: "val1",
Set2: 1024,
Set3: 2 * time.Millisecond,
Set4: nil,
Set5: map[string]interface{}{"k1": 1},
})
Expect(mSet.Err()).NotTo(HaveOccurred())
Expect(mSet.Val()).To(Equal("OK"))
mGet = client.MGet(ctx, "set1", "set2", "set3", "set4")
Expect(mGet.Err()).NotTo(HaveOccurred())
Expect(mGet.Val()).To(Equal([]interface{}{
"val1",
"1024",
strconv.Itoa(int(2 * time.Millisecond.Nanoseconds())),
"",
}))
})
})