Skip to content

Commit 1c5ec29

Browse files
committed
refactor: replace unwrap calls with descriptive expect messages in test suites
1 parent f63eaae commit 1c5ec29

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/hooks/normalize.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,18 @@ mod tests {
450450

451451
#[test]
452452
fn test_extract_array_content() {
453-
let json: Value = serde_json::from_str(
453+
let json: serde_json::Value = serde_json::from_str(
454454
r#"[{"type":"text","text":"hello"},{"type":"text","text":"world"}]"#,
455455
)
456-
.unwrap();
457-
let content = extract_value_content(&json).unwrap();
456+
.expect("Valid JSON");
457+
let content = extract_value_content(&json).expect("Content exists");
458458
assert_eq!(content, "hello\nworld");
459459
}
460460

461461
#[test]
462462
fn test_normalize_claude() {
463463
let input = r#"{"tool_name":"Bash","tool_input":{"command":"echo hello"},"tool_response":{"stdout":"hello"}}"#;
464-
let norm = normalize(input).unwrap();
464+
let norm = normalize(input).expect("Normalized successfully");
465465
assert_eq!(norm.agent_id, "claude_code");
466466
assert_eq!(norm.tool_name, "Bash");
467467
assert_eq!(norm.content, "hello");
@@ -471,7 +471,7 @@ mod tests {
471471
fn test_normalize_opencode() {
472472
let input =
473473
r#"{"type":"tool_result","tool":"shell","output":"hello","command":"echo hello"}"#;
474-
let norm = normalize(input).unwrap();
474+
let norm = normalize(input).expect("Normalized successfully");
475475
assert_eq!(norm.agent_id, "opencode");
476476
assert_eq!(norm.tool_name, "Bash");
477477
assert_eq!(norm.content, "hello");

src/hooks/post_tool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ mod tests {
682682
});
683683
let out = process_payload(&input.to_string(), None, None);
684684
assert!(out.is_some(), "Large ReadFile must be distilled");
685-
let res = out.unwrap();
685+
let res = out.expect("Output exists");
686686
assert!(
687687
res.contains("OMNI ReadFile"),
688688
"Must have OMNI ReadFile label"
@@ -708,7 +708,7 @@ mod tests {
708708
});
709709
let out = process_payload(&input.to_string(), None, None);
710710
assert!(out.is_some(), "Grep output must be distilled");
711-
let res = out.unwrap();
711+
let res = out.expect("Output exists");
712712
assert!(res.contains("OMNI Grep"), "Must have OMNI Grep label");
713713
assert!(res.contains("matches"), "Must show match count");
714714
}
@@ -784,7 +784,7 @@ mod tests {
784784
});
785785
let out = process_payload(&input.to_string(), None, None);
786786
assert!(out.is_some());
787-
let res = out.unwrap();
787+
let res = out.expect("Output exists");
788788
println!("PASSTHROUGH RES: {}", res);
789789
assert!(res.contains("OMNI: Passthrough"));
790790
}

0 commit comments

Comments
 (0)