mirror of
https://github.com/redis/go-redis.git
synced 2025-06-12 14:21:52 +03:00
Add support for MODULE LOADEX command (#2490)
* Added support for MODULE LOADEX command Co-authored-by: Anurag Bandyopadhyay <angbpy@gmail.com>
This commit is contained in:
@ -1926,11 +1926,59 @@ var _ = Describe("Commands", func() {
|
||||
Expect(replace.Val()).To(Equal(int64(1)))
|
||||
})
|
||||
|
||||
It("should acl dryryn", func() {
|
||||
It("should acl dryrun", func() {
|
||||
dryRun := client.ACLDryRun(ctx, "default", "get", "randomKey")
|
||||
Expect(dryRun.Err()).NotTo(HaveOccurred())
|
||||
Expect(dryRun.Val()).To(Equal("OK"))
|
||||
})
|
||||
|
||||
It("should fail module loadex", func() {
|
||||
dryRun := client.ModuleLoadex(ctx, &redis.ModuleLoadexConfig{
|
||||
Path: "/path/to/non-existent-library.so",
|
||||
Conf: map[string]interface{}{
|
||||
"param1": "value1",
|
||||
},
|
||||
Args: []interface{}{
|
||||
"arg1",
|
||||
},
|
||||
})
|
||||
Expect(dryRun.Err()).To(HaveOccurred())
|
||||
Expect(dryRun.Err().Error()).To(Equal("ERR Error loading the extension. Please check the server logs."))
|
||||
})
|
||||
|
||||
It("converts the module loadex configuration to a slice of arguments correctly", func() {
|
||||
conf := &redis.ModuleLoadexConfig{
|
||||
Path: "/path/to/your/module.so",
|
||||
Conf: map[string]interface{}{
|
||||
"param1": "value1",
|
||||
},
|
||||
Args: []interface{}{
|
||||
"arg1",
|
||||
"arg2",
|
||||
3,
|
||||
},
|
||||
}
|
||||
|
||||
args := conf.ToArgs()
|
||||
|
||||
// Test if the arguments are in the correct order
|
||||
expectedArgs := []interface{}{
|
||||
"MODULE",
|
||||
"LOADEX",
|
||||
"/path/to/your/module.so",
|
||||
"CONFIG",
|
||||
"param1",
|
||||
"value1",
|
||||
"ARGS",
|
||||
"arg1",
|
||||
"ARGS",
|
||||
"arg2",
|
||||
"ARGS",
|
||||
3,
|
||||
}
|
||||
|
||||
Expect(args).To(Equal(expectedArgs))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("hashes", func() {
|
||||
|
Reference in New Issue
Block a user