From 312d17c161cba7080bddef41292ec2a113685568 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 14:50:04 +0000 Subject: [PATCH] test(services): add error path test for MemoryContext::read_content This commit adds a unit test to verify that `MemoryContext::read_content` correctly returns a `ServiceError::Execution` error when attempting to read a source that does not exist in the context. The test ensures that the error variant is correct and that the error message contains the expected diagnostic information. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- crates/services/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/services/src/lib.rs b/crates/services/src/lib.rs index c932db7..f89708b 100644 --- a/crates/services/src/lib.rs +++ b/crates/services/src/lib.rs @@ -235,4 +235,18 @@ mod tests { let sources = ctx.list_sources().unwrap(); assert_eq!(sources, vec!["test.rs"]); } + + #[test] + fn test_memory_context_read_content_error() { + let ctx = MemoryContext::new(); + let result = ctx.read_content("non_existent.rs"); + assert!(result.is_err()); + + match result.unwrap_err() { + ServiceError::Execution { message } => { + assert!(message.contains("Source not found: non_existent.rs")); + } + _ => panic!("Expected ServiceError::Execution"), + } + } }