From 44d809f55a57c470056ff78a848022c1061a973f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 3 Jun 2026 14:21:01 +0000 Subject: [PATCH] test: remove vacuous guard tests and duplicate URL-encoding tests in wiki safe outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - create_wiki_page.rs: remove test_page_already_exists_guard_returns_failure and test_new_page_passes_guard — both tests construct a local if/else conditional inline and assert on the result; they never call execute_impl or any production code. The doc-comments themselves note 'if the guard were accidentally removed from execute_impl, this test would still pass.' - update_wiki_page.rs: remove test_page_not_found_guard_returns_failure and test_existing_page_passes_guard — same vacuous pattern. - update_wiki_page.rs: remove test_path_segment_encodes_fragment_delimiter, test_path_segment_encodes_query_delimiter, test_path_segment_encodes_space, test_path_segment_does_not_encode_safe_chars — identical copies of the same four tests already present in create_wiki_page.rs; both modules use the same PATH_SEGMENT constant from super::. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/safeoutputs/create_wiki_page.rs | 47 +-------------------- src/safeoutputs/update_wiki_page.rs | 64 +---------------------------- 2 files changed, 2 insertions(+), 109 deletions(-) diff --git a/src/safeoutputs/create_wiki_page.rs b/src/safeoutputs/create_wiki_page.rs index 98f31378..7ef221b9 100644 --- a/src/safeoutputs/create_wiki_page.rs +++ b/src/safeoutputs/create_wiki_page.rs @@ -882,52 +882,7 @@ wiki-name: "MyProject.wiki" // already-exists guard is reachable; the no-network path verifies the // guard logic via the unit test below. let _ = result.execute_impl(&ctx).await; - // (we cannot assert success/failure here without a real server; - // the guard itself is exercised by test_page_already_exists_guard_returns_failure) - } - - /// Unit test for the page-already-exists guard logic. - /// - /// NOTE: This test verifies the conditional logic prototype in isolation — - /// it does *not* call `execute_impl` directly. If the guard were accidentally - /// removed from `execute_impl`, this test would still pass. The integration - /// tests in `tests/compiler_tests.rs` and the network-level test - /// `test_execute_page_already_exists_is_rejected` (which calls `execute_impl` - /// against a fake host) together catch regressions in the live code path. - #[test] - fn test_page_already_exists_guard_returns_failure() { - // Simulate the logic: if page_exists → failure. - let page_exists = true; - let effective_path = "/Agent/Page"; - let result = if page_exists { - Some(ExecutionResult::failure(format!( - "Wiki page '{effective_path}' already exists. \ - Use the update-wiki-page safe output to update existing pages." - ))) - } else { - None - }; - assert!(result.is_some()); - assert!(!result.unwrap().success); - } - - /// Confirm that a non-existent page (page_exists = false) proceeds past the guard. - /// - /// NOTE: Same caveat as `test_page_already_exists_guard_returns_failure` above — - /// this tests the logic prototype, not the live `execute_impl` code path. - #[test] - fn test_new_page_passes_guard() { - let page_exists = false; - let effective_path = "/Agent/NewPage"; - let result: Option = if page_exists { - Some(ExecutionResult::failure(format!( - "Wiki page '{effective_path}' already exists. \ - Use the update-wiki-page safe output to update existing pages." - ))) - } else { - None - }; - assert!(result.is_none()); + // (we cannot assert success/failure here without a real server) } // ── URL encoding ────────────────────────────────────────────────────────── diff --git a/src/safeoutputs/update_wiki_page.rs b/src/safeoutputs/update_wiki_page.rs index 7528b362..8294224d 100644 --- a/src/safeoutputs/update_wiki_page.rs +++ b/src/safeoutputs/update_wiki_page.rs @@ -854,68 +854,6 @@ wiki-name: "MyProject.wiki" // path-not-found guard is reachable; the no-network path verifies the // guard logic via the unit test below. let _ = result.execute_impl(&ctx).await; - // (we cannot assert success/failure here without a real server; - // the guard itself is exercised by test_page_not_found_guard_returns_failure) - } - - /// Unit test for the page-not-found guard (no HTTP call needed). - #[test] - fn test_page_not_found_guard_returns_failure() { - // Simulate the logic that replaced check_create_if_missing_guard: - // if !page_exists → failure. - let page_exists = false; - let effective_path = "/Agent/Page"; - let result = if !page_exists { - Some(ExecutionResult::failure(format!( - "Wiki page '{effective_path}' does not exist. \ - Use a separate safe output to create new pages." - ))) - } else { - None - }; - assert!(result.is_some()); - assert!(!result.unwrap().success); - } - - /// Confirm that an existing page (page_exists = true) proceeds past the guard. - #[test] - fn test_existing_page_passes_guard() { - let page_exists = true; - let effective_path = "/Agent/Page"; - let result: Option = if !page_exists { - Some(ExecutionResult::failure(format!( - "Wiki page '{effective_path}' does not exist. \ - Use a separate safe output to create new pages." - ))) - } else { - None - }; - assert!(result.is_none()); - } - - // ── URL encoding ────────────────────────────────────────────────────────── - - #[test] - fn test_path_segment_encodes_fragment_delimiter() { - let encoded = utf8_percent_encode("wiki#name", PATH_SEGMENT).to_string(); - assert_eq!(encoded, "wiki%23name"); - } - - #[test] - fn test_path_segment_encodes_query_delimiter() { - let encoded = utf8_percent_encode("wiki?name", PATH_SEGMENT).to_string(); - assert_eq!(encoded, "wiki%3Fname"); - } - - #[test] - fn test_path_segment_encodes_space() { - let encoded = utf8_percent_encode("My Project", PATH_SEGMENT).to_string(); - assert_eq!(encoded, "My%20Project"); - } - - #[test] - fn test_path_segment_does_not_encode_safe_chars() { - let encoded = utf8_percent_encode("MyProject.wiki", PATH_SEGMENT).to_string(); - assert_eq!(encoded, "MyProject.wiki"); + // (we cannot assert success/failure here without a real server) } }