Skip to content

Commit 7111436

Browse files
committed
Initial testing
1 parent 233f97a commit 7111436

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ require (
1010
)
1111

1212
retract (
13-
v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead.
1413
v9.5.4 // This version was accidentally released. Please use version 9.6.0 instead.
14+
v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead.
1515
)

redis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
431431
return false, err
432432
}
433433
}
434-
434+
panic(cmd.firstKeyPos())
435435
retryTimeout := uint32(0)
436436
if err := c.withConn(ctx, func(ctx context.Context, cn *pool.Conn) error {
437437
if err := cn.WithWriter(c.context(ctx), c.opt.WriteTimeout, func(wr *proto.Writer) error {

redis_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"net"
9+
"strconv"
910
"testing"
1011
"time"
1112

@@ -633,3 +634,55 @@ var _ = Describe("Hook with MinIdleConns", func() {
633634
}))
634635
})
635636
})
637+
638+
var _ = Describe("Command Name", func() {
639+
var client *redis.Client
640+
641+
BeforeEach(func() {
642+
client = redis.NewClient(redisOptions())
643+
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
644+
})
645+
646+
AfterEach(func() {
647+
err := client.Close()
648+
Expect(err).NotTo(HaveOccurred())
649+
})
650+
651+
It("should return key name", func() {
652+
mSet := client.MSet(ctx, "key1", "hello1", "key2", "hello2")
653+
Expect(mSet.Err()).NotTo(HaveOccurred())
654+
Expect(mSet.Val()).To(Equal("OK"))
655+
Expect(mSet.Args()).To(Equal([]string{"MSET", "key1", "hello1", "key2", "hello2"}))
656+
657+
mGet := client.MGet(ctx, "key1", "key2", "_")
658+
Expect(mGet.Err()).NotTo(HaveOccurred())
659+
Expect(mGet.Val()).To(Equal([]interface{}{"hello1", "hello2", nil}))
660+
661+
// MSet struct
662+
type set struct {
663+
Set1 string `redis:"set1"`
664+
Set2 int16 `redis:"set2"`
665+
Set3 time.Duration `redis:"set3"`
666+
Set4 interface{} `redis:"set4"`
667+
Set5 map[string]interface{} `redis:"-"`
668+
}
669+
mSet = client.MSet(ctx, &set{
670+
Set1: "val1",
671+
Set2: 1024,
672+
Set3: 2 * time.Millisecond,
673+
Set4: nil,
674+
Set5: map[string]interface{}{"k1": 1},
675+
})
676+
Expect(mSet.Err()).NotTo(HaveOccurred())
677+
Expect(mSet.Val()).To(Equal("OK"))
678+
679+
mGet = client.MGet(ctx, "set1", "set2", "set3", "set4")
680+
Expect(mGet.Err()).NotTo(HaveOccurred())
681+
Expect(mGet.Val()).To(Equal([]interface{}{
682+
"val1",
683+
"1024",
684+
strconv.Itoa(int(2 * time.Millisecond.Nanoseconds())),
685+
"",
686+
}))
687+
})
688+
})

0 commit comments

Comments
 (0)