@@ -6277,6 +6277,57 @@ var _ = Describe("Commands", func() {
62776277 Expect (err ).To (Equal (redis .Nil ))
62786278 })
62796279
6280+ It ("should return all command names" , func () {
6281+ cmdList := client .CommandList (ctx , nil )
6282+ Expect (cmdList .Err ()).NotTo (HaveOccurred ())
6283+ cmdNames := cmdList .Val ()
6284+
6285+ Expect (cmdNames ).NotTo (BeEmpty ())
6286+
6287+ // Assert that some expected commands are present in the list
6288+ Expect (cmdNames ).To (ContainElement ("get" ))
6289+ Expect (cmdNames ).To (ContainElement ("set" ))
6290+ Expect (cmdNames ).To (ContainElement ("hset" ))
6291+ })
6292+
6293+ It ("should filter commands by module" , func () {
6294+ filter := & redis.FilterBy {
6295+ Module : "JSON" ,
6296+ }
6297+ cmdList := client .CommandList (ctx , filter )
6298+ Expect (cmdList .Err ()).NotTo (HaveOccurred ())
6299+ Expect (cmdList .Val ()).To (HaveLen (0 ))
6300+ })
6301+
6302+ It ("should filter commands by ACL category" , func () {
6303+
6304+ filter := & redis.FilterBy {
6305+ ACLCat : "admin" ,
6306+ }
6307+
6308+ cmdList := client .CommandList (ctx , filter )
6309+ Expect (cmdList .Err ()).NotTo (HaveOccurred ())
6310+ cmdNames := cmdList .Val ()
6311+
6312+ // Assert that the returned list only contains commands from the admin ACL category
6313+ Expect (len (cmdNames )).To (BeNumerically (">" , 10 ))
6314+ })
6315+
6316+ It ("should filter commands by pattern" , func () {
6317+ filter := & redis.FilterBy {
6318+ Pattern : "*GET*" ,
6319+ }
6320+ cmdList := client .CommandList (ctx , filter )
6321+ Expect (cmdList .Err ()).NotTo (HaveOccurred ())
6322+ cmdNames := cmdList .Val ()
6323+
6324+ // Assert that the returned list only contains commands that match the given pattern
6325+ Expect (cmdNames ).To (ContainElement ("get" ))
6326+ Expect (cmdNames ).To (ContainElement ("getbit" ))
6327+ Expect (cmdNames ).To (ContainElement ("getrange" ))
6328+ Expect (cmdNames ).NotTo (ContainElement ("set" ))
6329+ })
6330+
62806331 It ("Dump and restores all libraries" , func () {
62816332 err := client .FunctionLoad (ctx , lib1Code ).Err ()
62826333 Expect (err ).NotTo (HaveOccurred ())
0 commit comments