Skip to content

Commit 386e0f0

Browse files
aksh-02monkey92t
andauthored
Add support for acl dryrun command (redis#2502)
* add support for acl dryrun command Co-authored-by: Monkey <golang@88.com>
1 parent 984bc28 commit 386e0f0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

commands.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ type Cmdable interface {
452452
GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd
453453
GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd
454454
GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd
455+
456+
ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
455457
}
456458

457459
type StatefulCmdable interface {
@@ -3757,3 +3759,12 @@ func (c cmdable) GeoPos(ctx context.Context, key string, members ...string) *Geo
37573759
_ = c(ctx, cmd)
37583760
return cmd
37593761
}
3762+
3763+
func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd {
3764+
args := make([]interface{}, 0, 3+len(command))
3765+
args = append(args, "acl", "dryrun", username)
3766+
args = append(args, command...)
3767+
cmd := NewStringCmd(ctx, args...)
3768+
_ = c(ctx, cmd)
3769+
return cmd
3770+
}

commands_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,12 @@ var _ = Describe("Commands", func() {
18741874
replace := client.Copy(ctx, "newKey", "key", redisOptions().DB, true)
18751875
Expect(replace.Val()).To(Equal(int64(1)))
18761876
})
1877+
1878+
It("should acl dryryn", func() {
1879+
dryRun := client.ACLDryRun(ctx, "default", "get", "randomKey")
1880+
Expect(dryRun.Err()).NotTo(HaveOccurred())
1881+
Expect(dryRun.Val()).To(Equal("OK"))
1882+
})
18771883
})
18781884

18791885
Describe("hashes", func() {

0 commit comments

Comments
 (0)