Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,27 @@ var _ = Describe("withConn", func() {
Expect(client.connPool.Len()).To(Equal(1))
})
})

var _ = Describe("ClusterClient", func() {
var client *ClusterClient

BeforeEach(func() {
client = &ClusterClient{}
})

Describe("cmdSlot", func() {
It("select slot from args for GETKEYSINSLOT command", func() {
cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", 100, 200)

slot := client.cmdSlot(context.Background(), cmd)
Expect(slot).To(Equal(100))
})

It("select slot from args for COUNTKEYSINSLOT command", func() {
cmd := NewStringSliceCmd(ctx, "cluster", "countkeysinslot", 100)

slot := client.cmdSlot(context.Background(), cmd)
Expect(slot).To(Equal(100))
})
})
})
2 changes: 1 addition & 1 deletion osscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ func (c *ClusterClient) cmdInfo(ctx context.Context, name string) *CommandInfo {

func (c *ClusterClient) cmdSlot(ctx context.Context, cmd Cmder) int {
args := cmd.Args()
if args[0] == "cluster" && args[1] == "getkeysinslot" {
if args[0] == "cluster" && (args[1] == "getkeysinslot" || args[1] == "countkeysinslot") {
return args[2].(int)
}

Expand Down
Loading