From 8d3c6333619e511b5f103f382d21a9891dd0e794 Mon Sep 17 00:00:00 2001 From: omagdy Date: Tue, 22 Jul 2025 06:08:36 +0300 Subject: feat: Added a feature to proprely parse rdb files and added support for KEYS command --- tests/test_commands.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tests/test_commands.rs') 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 = -- cgit v1.2.3