From 2a15d3adb79b15ffb66c1ef73050a69bb5ea8d50 Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Mon, 10 Aug 2026 19:10:32 +0000 Subject: [PATCH] Add test: dry-run quarantines failing tests without uploading Covers the combination of --dry-run with quarantining enabled: a failing test marked for quarantine by the server overrides the exit code to 0, the quarantine-config endpoint is the only request made (no bundle upload or telemetry), and the locally written meta.json records the quarantined test. Co-Authored-By: Claude Fable 5 --- cli/tests/upload.rs | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/cli/tests/upload.rs b/cli/tests/upload.rs index 5ef44723..072c67ab 100644 --- a/cli/tests/upload.rs +++ b/cli/tests/upload.rs @@ -791,6 +791,78 @@ async fn upload_bundle_using_dry_run() { println!("{assert}"); } +#[tokio::test(flavor = "multi_thread")] +async fn dry_run_quarantines_failing_test_without_uploading() { + let temp_dir = tempdir().unwrap(); + generate_mock_git_repo(&temp_dir); + + let junit_location = temp_dir.path().join("junit.xml"); + let mut junit_file = fs::File::create(junit_location).unwrap(); + write!(junit_file, r#" + + + + + + Test failed + + + + + "#).unwrap(); + + let mut mock_server_builder = MockServerBuilder::new(); + #[axum::debug_handler] + async fn quarantine_all_handler( + State(state): State, + Json(request): Json, + ) -> Json { + let quarantined_tests = request + .test_identifiers + .iter() + .map(|t| t.id.clone()) + .collect(); + state + .requests + .lock() + .unwrap() + .push(RequestPayload::GetQuarantineConfig(request)); + Json(GetQuarantineConfigResponse { + is_disabled: false, + quarantined_tests, + ..Default::default() + }) + } + mock_server_builder.set_get_quarantining_config_handler(quarantine_all_handler); + let state = mock_server_builder.spawn_mock_server().await; + + let assert = CommandBuilder::upload(temp_dir.path(), state.host.clone()) + .junit_paths("junit.xml") + .dry_run(true) + .disable_quarantining(false) + .command() + .assert() + .success(); + + // The quarantine check still runs under dry run — the failing test is quarantined, + // overriding the exit code to 0 — but no upload or telemetry requests are made. + let requests = state.requests.lock().unwrap().clone(); + assert_eq!(requests.len(), 1); + assert_matches!(requests[0], RequestPayload::GetQuarantineConfig(..)); + + let output_dir = temp_dir.path().join(DRY_RUN_OUTPUT_DIR); + let meta_json = fs::File::open(output_dir.join("meta.json")).unwrap(); + let bundle_meta: BundleMeta = serde_json::from_reader(meta_json).unwrap(); + assert_eq!(bundle_meta.base_props.quarantined_tests.len(), 1); + assert_eq!( + bundle_meta.base_props.quarantined_tests[0].name, + "Product Parsers > Server-side parsers > has parsers for all products" + ); + + // HINT: View CLI output with `cargo test -- --nocapture` + println!("{assert}"); +} + #[tokio::test(flavor = "multi_thread")] async fn upload_bundle_success_status_code() { let temp_dir = tempdir().unwrap();