()
| 11 | |
| 12 | #[tokio::test] |
| 13 | async fn test_agent_defaults() { |
| 14 | let _ = tracing_subscriber::fmt::try_init(); |
| 15 | |
| 16 | const AMAZON_Q_MD_CONTENT: &str = "AmazonQ.md-FILE-CONTENT"; |
| 17 | const AGENTS_MD_CONTENT: &str = "AGENTS.md-FILE-CONTENT"; |
| 18 | const README_MD_CONTENT: &str = "README.md-FILE-CONTENT"; |
| 19 | const LOCAL_RULE_MD_CONTENT: &str = "local_rule.md-FILE-CONTENT"; |
| 20 | const SUB_LOCAL_RULE_MD_CONTENT: &str = "sub_local_rule.md-FILE-CONTENT"; |
| 21 | |
| 22 | let mut test = TestCase::builder() |
| 23 | .test_name("agent default config behavior") |
| 24 | .with_agent_config(AgentConfig::default()) |
| 25 | .with_file(("AmazonQ.md", AMAZON_Q_MD_CONTENT)) |
| 26 | .with_file(("AGENTS.md", AGENTS_MD_CONTENT)) |
| 27 | .with_file(("README.md", README_MD_CONTENT)) |
| 28 | .with_file((".amazonq/rules/local_rule.md", LOCAL_RULE_MD_CONTENT)) |
| 29 | .with_file((".amazonq/rules/subfolder/sub_local_rule.md", SUB_LOCAL_RULE_MD_CONTENT)) |
| 30 | .with_responses( |
| 31 | parse_response_streams(include_str!("./mock_responses/builtin_tools.jsonl")) |
| 32 | .await |
| 33 | .unwrap(), |
| 34 | ) |
| 35 | .with_tool_use_approvals([ |
| 36 | SendApprovalResultArgs { |
| 37 | id: "tooluse_first".into(), |
| 38 | result: ApprovalResult::Approve, |
| 39 | }, |
| 40 | SendApprovalResultArgs { |
| 41 | id: "tooluse_second".into(), |
| 42 | result: ApprovalResult::Approve, |
| 43 | }, |
| 44 | SendApprovalResultArgs { |
| 45 | id: "tooluse_third".into(), |
| 46 | result: ApprovalResult::Approve, |
| 47 | }, |
| 48 | ]) |
| 49 | .build() |
| 50 | .await |
| 51 | .unwrap(); |
| 52 | |
| 53 | test.send_prompt("start turn".to_string()).await; |
| 54 | |
| 55 | test.wait_until_agent_stop(Duration::from_secs(2)).await; |
| 56 | |
| 57 | for req in test.requests() { |
| 58 | let first_msg = req.messages().first().expect("first message should exist").text(); |
| 59 | let assert_contains = |expected: &str| { |
| 60 | assert!( |
| 61 | first_msg.contains(expected), |
| 62 | "expected to find '{}' inside content: '{}'", |
| 63 | expected, |
| 64 | first_msg |
| 65 | ); |
| 66 | }; |
| 67 | assert_contains(AMAZON_Q_MD_CONTENT); |
| 68 | assert_contains(AGENTS_MD_CONTENT); |
| 69 | assert_contains(README_MD_CONTENT); |
| 70 | assert_contains(LOCAL_RULE_MD_CONTENT); |
nothing calls this directly
no test coverage detected