diff options
| author | omagdy <omar.professional8777@gmail.com> | 2025-07-22 06:08:36 +0300 |
|---|---|---|
| committer | omagdy <omar.professional8777@gmail.com> | 2025-07-22 06:10:05 +0300 |
| commit | 8d3c6333619e511b5f103f382d21a9891dd0e794 (patch) | |
| tree | 67f9bb412c7eadecacf50e44caa29137c0a07ff5 /tests/test_commands.rs | |
| parent | 846479e6bcf8238879546534b09e141b9bb668f8 (diff) | |
| download | redis-rust-8d3c6333619e511b5f103f382d21a9891dd0e794.tar.xz redis-rust-8d3c6333619e511b5f103f382d21a9891dd0e794.zip | |
feat: Added a feature to proprely parse rdb files and added support for KEYS command
Diffstat (limited to 'tests/test_commands.rs')
| -rw-r--r-- | tests/test_commands.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/test_commands.rs b/tests/test_commands.rs index 1031c8b..e71db38 100644 --- a/tests/test_commands.rs +++ b/tests/test_commands.rs @@ -37,13 +37,13 @@ mod command_parser_tests { #[test] fn test_parse_ping() { let cmd = build_command_from_str_slice(&["PING"]); - assert!(matches!(RedisCommands::from(cmd), RedisCommands::PING)); + assert!(matches!(RedisCommands::from(cmd), RedisCommands::Ping)); } #[test] fn test_parse_ping_case_insensitive() { let cmd = build_command_from_str_slice(&["pInG"]); - assert!(matches!(RedisCommands::from(cmd), RedisCommands::PING)); + assert!(matches!(RedisCommands::from(cmd), RedisCommands::Ping)); } #[test] @@ -56,7 +56,7 @@ mod command_parser_tests { fn test_parse_echo() { let cmd = build_command_from_str_slice(&["ECHO", "hello world"]); match RedisCommands::from(cmd) { - RedisCommands::ECHO(s) => assert_eq!(s, "hello world"), + RedisCommands::Echo(s) => assert_eq!(s, "hello world"), _ => panic!("Expected ECHO command"), } } @@ -71,7 +71,7 @@ mod command_parser_tests { fn test_parse_get() { let cmd = build_command_from_str_slice(&["GET", "mykey"]); match RedisCommands::from(cmd) { - RedisCommands::GET(k) => assert_eq!(k, "mykey"), + RedisCommands::Get(k) => assert_eq!(k, "mykey"), _ => panic!("Expected GET command"), } } @@ -80,7 +80,7 @@ mod command_parser_tests { fn test_parse_simple_set() { let cmd = build_command_from_str_slice(&["SET", "mykey", "myvalue"]); match RedisCommands::from(cmd) { - RedisCommands::SET(c) => { + RedisCommands::Set(c) => { assert_eq!(c.key, "mykey"); assert_eq!(c.value, "myvalue"); assert!(c.condition.is_none() && c.expiry.is_none() && !c.get_old_value); @@ -93,7 +93,7 @@ mod command_parser_tests { fn test_parse_set_with_all_options() { let cmd = build_command_from_str_slice(&["SET", "k", "v", "NX", "PX", "5000", "GET"]); match RedisCommands::from(cmd) { - RedisCommands::SET(c) => { + RedisCommands::Set(c) => { assert!(matches!(c.condition, Some(SetCondition::NotExists))); assert!(matches!(c.expiry, Some(ExpiryOption::Milliseconds(5000)))); assert!(c.get_old_value); @@ -106,7 +106,7 @@ mod command_parser_tests { fn test_parse_set_options_case_insensitive() { let cmd = build_command_from_str_slice(&["set", "k", "v", "nx", "px", "100"]); match RedisCommands::from(cmd) { - RedisCommands::SET(c) => { + RedisCommands::Set(c) => { assert!(matches!(c.condition, Some(SetCondition::NotExists))); assert!(matches!(c.expiry, Some(ExpiryOption::Milliseconds(100)))); } @@ -267,8 +267,6 @@ mod set_command_tests { use codecrafters_redis::resp_commands::{ExpiryOption, SetCommand}; - use super::*; - #[test] fn test_calculate_expiry_seconds() { let cmd = |
