11use std:: collections:: HashMap ;
22
33use redis_module:: InfoContext ;
4- use redis_module:: { redis_module, Context , RedisError , RedisResult , RedisString } ;
4+ use redis_module:: { redis_module, RedisResult } ;
55use redis_module_macros:: info_command_handler;
66use redis_module_macros:: InfoSection ;
77
8- fn test_helper_version ( ctx : & Context , _args : Vec < RedisString > ) -> RedisResult {
9- let ver = ctx. get_redis_version ( ) ?;
10- let response: Vec < i64 > = vec ! [ ver. major. into( ) , ver. minor. into( ) , ver. patch. into( ) ] ;
11-
12- Ok ( response. into ( ) )
13- }
14-
15- fn test_helper_version_rm_call ( ctx : & Context , _args : Vec < RedisString > ) -> RedisResult {
16- let ver = ctx. get_redis_version_rm_call ( ) ?;
17- let response: Vec < i64 > = vec ! [ ver. major. into( ) , ver. minor. into( ) , ver. patch. into( ) ] ;
18-
19- Ok ( response. into ( ) )
20- }
21-
22- fn test_helper_command_name ( ctx : & Context , _args : Vec < RedisString > ) -> RedisResult {
23- Ok ( ctx. current_command_name ( ) ?. into ( ) )
24- }
25-
26- fn test_helper_err ( ctx : & Context , args : Vec < RedisString > ) -> RedisResult {
27- if args. len ( ) < 1 {
28- return Err ( RedisError :: WrongArity ) ;
29- }
30-
31- let msg = args. get ( 1 ) . unwrap ( ) ;
32-
33- ctx. reply_error_string ( msg. try_as_str ( ) . unwrap ( ) ) ;
34- Ok ( ( ) . into ( ) )
35- }
36-
378#[ derive( Debug , Clone , InfoSection ) ]
389struct InfoData {
3910 field : String ,
@@ -54,14 +25,9 @@ fn add_info(ctx: &InfoContext, _for_crash_report: bool) -> RedisResult<()> {
5425//////////////////////////////////////////////////////
5526
5627redis_module ! {
57- name: "test_helper " ,
28+ name: "info_handler_macro " ,
5829 version: 1 ,
5930 allocator: ( redis_module:: alloc:: RedisAlloc , redis_module:: alloc:: RedisAlloc ) ,
6031 data_types: [ ] ,
61- commands: [
62- [ "test_helper.version" , test_helper_version, "" , 0 , 0 , 0 ] ,
63- [ "test_helper._version_rm_call" , test_helper_version_rm_call, "" , 0 , 0 , 0 ] ,
64- [ "test_helper.name" , test_helper_command_name, "" , 0 , 0 , 0 ] ,
65- [ "test_helper.err" , test_helper_err, "" , 0 , 0 , 0 ] ,
66- ] ,
32+ commands: [ ] ,
6733}
0 commit comments