35 lines
1.3 KiB
Rust
35 lines
1.3 KiB
Rust
use redis_rs::protocol::Protocol;
|
|
use redis_rs::cmd::Cmd;
|
|
|
|
#[test]
|
|
fn test_protocol_parsing() {
|
|
// Test TYPE command parsing
|
|
let type_cmd = "*2\r\n$4\r\nTYPE\r\n$7\r\nnoexist\r\n";
|
|
println!("Parsing TYPE command: {}", type_cmd.replace("\r\n", "\\r\\n"));
|
|
|
|
match Protocol::from(type_cmd) {
|
|
Ok((protocol, _)) => {
|
|
println!("Protocol parsed successfully: {:?}", protocol);
|
|
match Cmd::from(type_cmd) {
|
|
Ok((cmd, _, _)) => println!("Command parsed successfully: {:?}", cmd),
|
|
Err(e) => println!("Command parsing failed: {:?}", e),
|
|
}
|
|
}
|
|
Err(e) => println!("Protocol parsing failed: {:?}", e),
|
|
}
|
|
|
|
// Test HEXISTS command parsing
|
|
let hexists_cmd = "*3\r\n$7\r\nHEXISTS\r\n$4\r\nhash\r\n$7\r\nnoexist\r\n";
|
|
println!("\nParsing HEXISTS command: {}", hexists_cmd.replace("\r\n", "\\r\\n"));
|
|
|
|
match Protocol::from(hexists_cmd) {
|
|
Ok((protocol, _)) => {
|
|
println!("Protocol parsed successfully: {:?}", protocol);
|
|
match Cmd::from(hexists_cmd) {
|
|
Ok((cmd, _, _)) => println!("Command parsed successfully: {:?}", cmd),
|
|
Err(e) => println!("Command parsing failed: {:?}", e),
|
|
}
|
|
}
|
|
Err(e) => println!("Protocol parsing failed: {:?}", e),
|
|
}
|
|
} |