Skip to content

Commit fc72d5f

Browse files
committed
add LMove with tests
1 parent 20322ac commit fc72d5f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

commands.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ type Cmdable interface {
191191
RPopLPush(ctx context.Context, source, destination string) *StringCmd
192192
RPush(ctx context.Context, key string, values ...interface{}) *IntCmd
193193
RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd
194+
LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd
194195

195196
SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd
196197
SCard(ctx context.Context, key string) *IntCmd
@@ -1431,6 +1432,12 @@ func (c cmdable) RPushX(ctx context.Context, key string, values ...interface{})
14311432
return cmd
14321433
}
14331434

1435+
func (c cmdable) LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd {
1436+
cmd := NewStringCmd(ctx, "lmove", source, destination, srcpos, destpos)
1437+
_ = c(ctx, cmd)
1438+
return cmd
1439+
}
1440+
14341441
//------------------------------------------------------------------------------
14351442

14361443
func (c cmdable) SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd {

commands_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,28 @@ var _ = Describe("Commands", func() {
23172317
Expect(lRange.Err()).NotTo(HaveOccurred())
23182318
Expect(lRange.Val()).To(Equal([]string{}))
23192319
})
2320+
2321+
It("should LMove", func() {
2322+
rPush := client.RPush(ctx, "lmove1", "ichi")
2323+
Expect(rPush.Err()).NotTo(HaveOccurred())
2324+
Expect(rPush.Val()).To(Equal(int64(1)))
2325+
2326+
rPush = client.RPush(ctx, "lmove1", "ni")
2327+
Expect(rPush.Err()).NotTo(HaveOccurred())
2328+
Expect(rPush.Val()).To(Equal(int64(2)))
2329+
2330+
rPush = client.RPush(ctx, "lmove1", "san")
2331+
Expect(rPush.Err()).NotTo(HaveOccurred())
2332+
Expect(rPush.Val()).To(Equal(int64(3)))
2333+
2334+
lMove := client.LMove(ctx, "lmove1", "lmove2", "RIGHT", "LEFT")
2335+
Expect(lMove.Err()).NotTo(HaveOccurred())
2336+
Expect(lMove.Val()).To(Equal("san"))
2337+
2338+
lRange := client.LRange(ctx, "lmove2", 0, -1)
2339+
Expect(lRange.Err()).NotTo(HaveOccurred())
2340+
Expect(lRange.Val()).To(Equal([]string{"san"}))
2341+
})
23202342
})
23212343

23222344
Describe("sets", func() {

0 commit comments

Comments
 (0)