Add support for acl dryrun command (#2502)

* add support for acl dryrun command

Co-authored-by: Monkey <golang@88.com>
This commit is contained in:
Akshay Gandhi 2023-03-26 19:51:46 +05:30 committed by GitHub
parent 984bc2810d
commit 386e0f0cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -452,6 +452,8 @@ type Cmdable interface {
GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd
GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd
GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd
ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
}
type StatefulCmdable interface {
@ -3757,3 +3759,12 @@ func (c cmdable) GeoPos(ctx context.Context, key string, members ...string) *Geo
_ = c(ctx, cmd)
return cmd
}
func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd {
args := make([]interface{}, 0, 3+len(command))
args = append(args, "acl", "dryrun", username)
args = append(args, command...)
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}

View File

@ -1874,6 +1874,12 @@ var _ = Describe("Commands", func() {
replace := client.Copy(ctx, "newKey", "key", redisOptions().DB, true)
Expect(replace.Val()).To(Equal(int64(1)))
})
It("should acl dryryn", func() {
dryRun := client.ACLDryRun(ctx, "default", "get", "randomKey")
Expect(dryRun.Err()).NotTo(HaveOccurred())
Expect(dryRun.Val()).To(Equal("OK"))
})
})
Describe("hashes", func() {