Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ndyakov committed Feb 4, 2025
1 parent e94b310 commit d5cea4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
11 changes: 3 additions & 8 deletions acl_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ func (c cmdable) ACLLogReset(ctx context.Context) *StatusCmd {
}

func (c cmdable) ACLDelUser(ctx context.Context, username string) *IntCmd {
args := make([]interface{}, 3, 3)
args[0] = "acl"
args[1] = "deluser"
args[2] = username
cmd := NewIntCmd(ctx, args...)
cmd := NewIntCmd(ctx, "acl", "deluser", username)
_ = c(ctx, cmd)
return cmd
}

func (c cmdable) ACLSetUser(ctx context.Context, username string, rules ...string) *StatusCmd {
args := make([]interface{}, 3+len(rules), 3+len(rules))
args := make([]interface{}, 3+len(rules))
args[0] = "acl"
args[1] = "setuser"
args[2] = username
Expand All @@ -84,8 +80,7 @@ func (c cmdable) ACLCat(ctx context.Context) *StringSliceCmd {
func (c cmdable) ACLCatArgs(ctx context.Context, options *ACLCatArgs) *StringSliceCmd {
// if there is a category passed, build new cmd, if there isn't - use the ACLCat method
if options != nil && options.Category != "" {
args := []interface{}{"acl", "cat", options.Category}
cmd := NewStringSliceCmd(ctx, args...)
cmd := NewStringSliceCmd(ctx, "acl", "cat", options.Category)
_ = c(ctx, cmd)
return cmd
}
Expand Down
19 changes: 17 additions & 2 deletions acl_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
)

var TestUserName string = "goredis"

var _ = Describe("ACL Commands", func() {
var _ = Describe("ACL Users Commands", Label("NonRedisEnterprise"), func() {
var client *redis.Client
var ctx context.Context

Expand Down Expand Up @@ -58,6 +57,21 @@ var _ = Describe("ACL Commands", func() {
Expect(resAfterDeletion[0]).To(BeEquivalentTo(res[0]))
})

})

var _ = Describe("ACL Categories", func() {
var client *redis.Client
var ctx context.Context

BeforeEach(func() {
ctx = context.Background()
client = redis.NewClient(redisOptions())
})

AfterEach(func() {
Expect(client.Close()).NotTo(HaveOccurred())
})

It("lists acl categories and subcategories", func() {
res, err := client.ACLCat(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -107,4 +121,5 @@ var _ = Describe("ACL Commands", func() {
Expect(err).NotTo(HaveOccurred())
Expect(res).To(ContainElements(cats...))
})

})

0 comments on commit d5cea4e

Please sign in to comment.