summaryrefslogtreecommitdiffstats
path: root/tests/tools.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/tools.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/tools.rs b/tests/tools.rs
index e54b5ff..4a8176e 100644
--- a/tests/tools.rs
+++ b/tests/tools.rs
@@ -490,3 +490,30 @@ fn bash_honours_a_per_call_output_budget() {
490 assert!(text.contains("output truncated"), "{text}"); 490 assert!(text.contains("output truncated"), "{text}");
491 assert!(text.len() < 10_000, "output was {} bytes", text.len()); 491 assert!(text.len() < 10_000, "output was {} bytes", text.len());
492} 492}
493
494#[test]
495fn validate_requires_content_and_new_but_allows_empty() {
496 use agent686::tools::validate;
497
498 // Missing, not empty.
499 assert!(validate("write", &json!({ "path": "a" })).is_err());
500 assert!(validate("edit", &json!({ "path": "a", "old": "b" })).is_err());
501 // Present but empty is legitimate (empty file, deletion).
502 assert!(validate("write", &json!({ "path": "a", "content": "" })).is_ok());
503 assert!(validate("edit", &json!({ "path": "a", "old": "b", "new": "" })).is_ok());
504}
505
506#[test]
507fn a_pipeline_that_exceeds_the_file_limit_is_reported() {
508 // 70 MiB through a pipeline: the grandchild (head) is the writer, so only the
509 // file-length check can detect the limit.
510 let text = run(
511 "bash",
512 &json!({ "cmd": "yes | head -c 70000000" }),
513 )
514 .unwrap();
515 assert!(
516 text.contains("output exceeded 64 MiB"),
517 "should report the file limit: {text}"
518 );
519}