Skip to content

Commit 7c14975

Browse files
committed
refactored to have common assert_contains function and finished verification for first AgentSpawn hook integration test
1 parent f3d1b8b commit 7c14975

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

crates/agent/tests/common/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,12 @@ pub async fn parse_response_streams(content: impl AsRef<str>) -> Result<MockResp
302302
}
303303
Ok(stream)
304304
}
305+
306+
pub fn assert_contains(text: &str, expected: &str) {
307+
assert!(
308+
text.contains(expected),
309+
"expected to find '{}' inside content: '{}'",
310+
expected,
311+
text
312+
);
313+
}

crates/agent/tests/mod.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,10 @@ async fn test_agent_defaults() {
5858

5959
for req in test.requests() {
6060
let first_msg = req.messages().first().expect("first message should exist").text();
61-
let assert_contains = |expected: &str| {
62-
assert!(
63-
first_msg.contains(expected),
64-
"expected to find '{}' inside content: '{}'",
65-
expected,
66-
first_msg
67-
);
68-
};
69-
assert_contains(AMAZON_Q_MD_CONTENT);
70-
assert_contains(AGENTS_MD_CONTENT);
71-
assert_contains(README_MD_CONTENT);
72-
assert_contains(LOCAL_RULE_MD_CONTENT);
73-
assert_contains(SUB_LOCAL_RULE_MD_CONTENT);
61+
assert_contains(&first_msg, AMAZON_Q_MD_CONTENT);
62+
assert_contains(&first_msg,AGENTS_MD_CONTENT);
63+
assert_contains(&first_msg,README_MD_CONTENT);
64+
assert_contains(&first_msg,LOCAL_RULE_MD_CONTENT);
65+
assert_contains(&first_msg,SUB_LOCAL_RULE_MD_CONTENT);
7466
}
7567
}

crates/agent/tests/test_hooks.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ async fn test_agent_spawn_hook() {
4545
info!("before stop");
4646
test.wait_until_agent_stop(Duration::from_secs(10)).await;
4747
info!("after stop");
48-
for (i, req) in test.requests().iter().enumerate() {
49-
info!("Request {}: {:#?}", i, req);
48+
for req in test.requests() {
49+
let first_msg = req.messages().first().expect("first message should exist").text();
50+
assert_contains(&first_msg, "Agent initialized");
5051
}
5152
}

0 commit comments

Comments
 (0)