Skip to content

Commit 87d5f1d

Browse files
test: remove vacuous guard tests and duplicate URL-encoding tests in wiki safe outputs (#844)
1 parent 6c7b72c commit 87d5f1d

2 files changed

Lines changed: 2 additions & 109 deletions

File tree

src/safeoutputs/create_wiki_page.rs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -882,52 +882,7 @@ wiki-name: "MyProject.wiki"
882882
// already-exists guard is reachable; the no-network path verifies the
883883
// guard logic via the unit test below.
884884
let _ = result.execute_impl(&ctx).await;
885-
// (we cannot assert success/failure here without a real server;
886-
// the guard itself is exercised by test_page_already_exists_guard_returns_failure)
887-
}
888-
889-
/// Unit test for the page-already-exists guard logic.
890-
///
891-
/// NOTE: This test verifies the conditional logic prototype in isolation —
892-
/// it does *not* call `execute_impl` directly. If the guard were accidentally
893-
/// removed from `execute_impl`, this test would still pass. The integration
894-
/// tests in `tests/compiler_tests.rs` and the network-level test
895-
/// `test_execute_page_already_exists_is_rejected` (which calls `execute_impl`
896-
/// against a fake host) together catch regressions in the live code path.
897-
#[test]
898-
fn test_page_already_exists_guard_returns_failure() {
899-
// Simulate the logic: if page_exists → failure.
900-
let page_exists = true;
901-
let effective_path = "/Agent/Page";
902-
let result = if page_exists {
903-
Some(ExecutionResult::failure(format!(
904-
"Wiki page '{effective_path}' already exists. \
905-
Use the update-wiki-page safe output to update existing pages."
906-
)))
907-
} else {
908-
None
909-
};
910-
assert!(result.is_some());
911-
assert!(!result.unwrap().success);
912-
}
913-
914-
/// Confirm that a non-existent page (page_exists = false) proceeds past the guard.
915-
///
916-
/// NOTE: Same caveat as `test_page_already_exists_guard_returns_failure` above —
917-
/// this tests the logic prototype, not the live `execute_impl` code path.
918-
#[test]
919-
fn test_new_page_passes_guard() {
920-
let page_exists = false;
921-
let effective_path = "/Agent/NewPage";
922-
let result: Option<ExecutionResult> = if page_exists {
923-
Some(ExecutionResult::failure(format!(
924-
"Wiki page '{effective_path}' already exists. \
925-
Use the update-wiki-page safe output to update existing pages."
926-
)))
927-
} else {
928-
None
929-
};
930-
assert!(result.is_none());
885+
// (we cannot assert success/failure here without a real server)
931886
}
932887

933888
// ── URL encoding ──────────────────────────────────────────────────────────

src/safeoutputs/update_wiki_page.rs

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -854,68 +854,6 @@ wiki-name: "MyProject.wiki"
854854
// path-not-found guard is reachable; the no-network path verifies the
855855
// guard logic via the unit test below.
856856
let _ = result.execute_impl(&ctx).await;
857-
// (we cannot assert success/failure here without a real server;
858-
// the guard itself is exercised by test_page_not_found_guard_returns_failure)
859-
}
860-
861-
/// Unit test for the page-not-found guard (no HTTP call needed).
862-
#[test]
863-
fn test_page_not_found_guard_returns_failure() {
864-
// Simulate the logic that replaced check_create_if_missing_guard:
865-
// if !page_exists → failure.
866-
let page_exists = false;
867-
let effective_path = "/Agent/Page";
868-
let result = if !page_exists {
869-
Some(ExecutionResult::failure(format!(
870-
"Wiki page '{effective_path}' does not exist. \
871-
Use a separate safe output to create new pages."
872-
)))
873-
} else {
874-
None
875-
};
876-
assert!(result.is_some());
877-
assert!(!result.unwrap().success);
878-
}
879-
880-
/// Confirm that an existing page (page_exists = true) proceeds past the guard.
881-
#[test]
882-
fn test_existing_page_passes_guard() {
883-
let page_exists = true;
884-
let effective_path = "/Agent/Page";
885-
let result: Option<ExecutionResult> = if !page_exists {
886-
Some(ExecutionResult::failure(format!(
887-
"Wiki page '{effective_path}' does not exist. \
888-
Use a separate safe output to create new pages."
889-
)))
890-
} else {
891-
None
892-
};
893-
assert!(result.is_none());
894-
}
895-
896-
// ── URL encoding ──────────────────────────────────────────────────────────
897-
898-
#[test]
899-
fn test_path_segment_encodes_fragment_delimiter() {
900-
let encoded = utf8_percent_encode("wiki#name", PATH_SEGMENT).to_string();
901-
assert_eq!(encoded, "wiki%23name");
902-
}
903-
904-
#[test]
905-
fn test_path_segment_encodes_query_delimiter() {
906-
let encoded = utf8_percent_encode("wiki?name", PATH_SEGMENT).to_string();
907-
assert_eq!(encoded, "wiki%3Fname");
908-
}
909-
910-
#[test]
911-
fn test_path_segment_encodes_space() {
912-
let encoded = utf8_percent_encode("My Project", PATH_SEGMENT).to_string();
913-
assert_eq!(encoded, "My%20Project");
914-
}
915-
916-
#[test]
917-
fn test_path_segment_does_not_encode_safe_chars() {
918-
let encoded = utf8_percent_encode("MyProject.wiki", PATH_SEGMENT).to_string();
919-
assert_eq!(encoded, "MyProject.wiki");
857+
// (we cannot assert success/failure here without a real server)
920858
}
921859
}

0 commit comments

Comments
 (0)