fix: create test static dir to prevent ServeDir/ServeFile hang

The SPA fallback uses ServeDir/ServeFile which can hang when the
directory doesn't exist. Create it in TestApp::new() with a minimal
index.html.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
master
oabrivard 3 months ago
parent cda9e2fc25
commit 7cbafdfb31

@ -117,6 +117,13 @@ impl TestApp {
turnstile_site_key: "test-site-key".into(), turnstile_site_key: "test-site-key".into(),
}; };
// Create the static dir so ServeDir/ServeFile don't hang
let _ = std::fs::create_dir_all(&config.static_dir);
let index_path = format!("{}/index.html", config.static_dir);
if !std::path::Path::new(&index_path).exists() {
let _ = std::fs::write(&index_path, "<html><body>test</body></html>");
}
let http_client = reqwest::Client::new(); let http_client = reqwest::Client::new();
let state = AppState::new(config.clone(), pool.clone(), http_client); let state = AppState::new(config.clone(), pool.clone(), http_client);
let router = build_router(state, &config); let router = build_router(state, &config);

Loading…
Cancel
Save