From c4404fc931f14813f4716d79496a4e1b5f17c231 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 24 Apr 2026 09:17:54 -0400 Subject: [PATCH] refactor(server): pr_test_app_with_minimal_run for create_run holdouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an async sibling helper that bundles state + app + a fresh create_run(&app, MINIMAL_DOT) into one (state, app, run_id) tuple. Updated the 2 PR tests that had built this triple manually (merge/close not_found_when_record_missing). The third holdout at line 10148 keeps its own setup — it has an intervening assert_eq!(state.github_api_base_url, github.base_url()) that documents a load-bearing invariant about app state construction. Verified: workspace fmt clean, clippy --all-targets -D warnings clean, cargo nextest run -p fabro-server 439 passed. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/crates/fabro-server/src/server.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/crates/fabro-server/src/server.rs b/lib/crates/fabro-server/src/server.rs index 73ee641a1..d3c8e2639 100644 --- a/lib/crates/fabro-server/src/server.rs +++ b/lib/crates/fabro-server/src/server.rs @@ -8953,6 +8953,20 @@ strategy = "token" (state, app, fixtures::RUN_1) } + /// Same as [`pr_test_app`] but creates a fresh minimal run via the + /// HTTP create-run endpoint instead of using fixtures::RUN_1. For + /// tests that exercise endpoints expecting a real on-disk run rather + /// than a synthetic fixture id. + async fn pr_test_app_with_minimal_run( + token: Option<&str>, + github_api_base_url: Option, + ) -> (Arc, Router, String) { + let state = create_github_token_app_state(token, github_api_base_url); + let app = build_router(Arc::clone(&state), AuthMode::Disabled); + let run_id = create_run(&app, MINIMAL_DOT).await; + (state, app, run_id) + } + async fn create_run_with_pull_request_record( state: &Arc, run_id: RunId, @@ -10166,9 +10180,7 @@ slug = "fabro" #[tokio::test] async fn merge_run_pull_request_returns_not_found_when_record_missing() { - let state = create_github_token_app_state(Some("ghu_test"), None); - let app = build_router(Arc::clone(&state), AuthMode::Disabled); - let run_id = create_run(&app, MINIMAL_DOT).await; + let (_state, app, run_id) = pr_test_app_with_minimal_run(Some("ghu_test"), None).await; let response = app .oneshot( @@ -10274,9 +10286,7 @@ slug = "fabro" #[tokio::test] async fn close_run_pull_request_returns_not_found_when_record_missing() { - let state = create_github_token_app_state(Some("ghu_test"), None); - let app = build_router(Arc::clone(&state), AuthMode::Disabled); - let run_id = create_run(&app, MINIMAL_DOT).await; + let (_state, app, run_id) = pr_test_app_with_minimal_run(Some("ghu_test"), None).await; let response = app .oneshot(