refactor(tests): migrate remaining batches to tests/common/
Finishes the lift of shared helpers into `tests/common/`. Covered: - health, web, oneliners_api, upload (31 tests; upload exercises the new `multipart_upload_body` helper driven by doctate_common field constants) - sse_integration, sse_cleanup, transcribe, oneliner_heal_decoupled, silent_case_empty, failed_only_case_empty_oneliner, transient_failure_retries (24 tests) Also applied cargo fmt across the test tree and fixed one clippy needless_borrows_for_generic_args warning in analyze_test. All 387 tests pass; 3 ignored (as before). Side effect: health_test previously used a hardcoded `/tmp/doctate-test` data path, which parallel `cargo test` runs could collide on. The migration replaces it with the common unique-tmpdir pattern, removing a latent flake.
This commit is contained in:
@@ -26,7 +26,11 @@ async fn trigger_sweep(app: &axum::Router, cookie: &str) {
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
fn build_cfg(label: &'static str, auto_close_days: u32, auto_delete_days: u32) -> std::sync::Arc<doctate_server::config::Config> {
|
||||
fn build_cfg(
|
||||
label: &'static str,
|
||||
auto_close_days: u32,
|
||||
auto_delete_days: u32,
|
||||
) -> std::sync::Arc<doctate_server::config::Config> {
|
||||
TestConfig::new()
|
||||
.with_label(label)
|
||||
.with_user(test_user_with_retention(
|
||||
@@ -93,11 +97,7 @@ async fn auto_close_respects_newest_recording() {
|
||||
"2026-04-01T10-00-00Z",
|
||||
Duration::from_secs(30 * 86400),
|
||||
);
|
||||
seed_recording_with_age(
|
||||
&case_dir,
|
||||
"2026-04-01T11-00-00Z",
|
||||
Duration::from_secs(60),
|
||||
);
|
||||
seed_recording_with_age(&case_dir, "2026-04-01T11-00-00Z", Duration::from_secs(60));
|
||||
|
||||
let app = doctate_server::create_router(cfg);
|
||||
let cookie = common::login(&app, "dr_a", "s").await;
|
||||
@@ -114,16 +114,9 @@ async fn auto_purge_removes_old_closed_case() {
|
||||
let cfg = build_cfg("purge-old", 0, 30);
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording_with_age(
|
||||
&case_dir,
|
||||
"2026-04-01T10-00-00Z",
|
||||
Duration::from_secs(60),
|
||||
);
|
||||
seed_recording_with_age(&case_dir, "2026-04-01T10-00-00Z", Duration::from_secs(60));
|
||||
// closed_at = 31 days ago → must be purged.
|
||||
write_closed_marker(
|
||||
&case_dir,
|
||||
&past_rfc3339(Duration::from_secs(31 * 86400)),
|
||||
);
|
||||
write_closed_marker(&case_dir, &past_rfc3339(Duration::from_secs(31 * 86400)));
|
||||
|
||||
let app = doctate_server::create_router(cfg);
|
||||
let cookie = common::login(&app, "dr_a", "s").await;
|
||||
@@ -142,15 +135,8 @@ async fn auto_purge_disabled_when_days_zero() {
|
||||
let cfg = build_cfg("purge-zero", 0, 0);
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording_with_age(
|
||||
&case_dir,
|
||||
"2026-04-01T10-00-00Z",
|
||||
Duration::from_secs(60),
|
||||
);
|
||||
write_closed_marker(
|
||||
&case_dir,
|
||||
&past_rfc3339(Duration::from_secs(365 * 86400)),
|
||||
);
|
||||
seed_recording_with_age(&case_dir, "2026-04-01T10-00-00Z", Duration::from_secs(60));
|
||||
write_closed_marker(&case_dir, &past_rfc3339(Duration::from_secs(365 * 86400)));
|
||||
|
||||
let app = doctate_server::create_router(cfg);
|
||||
let cookie = common::login(&app, "dr_a", "s").await;
|
||||
@@ -198,11 +184,7 @@ async fn auto_purge_skips_open_cases() {
|
||||
let cfg = build_cfg("purge-skip-open", 0, 30);
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording_with_age(
|
||||
&case_dir,
|
||||
"2026-04-01T10-00-00Z",
|
||||
Duration::from_secs(60),
|
||||
);
|
||||
seed_recording_with_age(&case_dir, "2026-04-01T10-00-00Z", Duration::from_secs(60));
|
||||
|
||||
let app = doctate_server::create_router(cfg);
|
||||
let cookie = common::login(&app, "dr_a", "s").await;
|
||||
|
||||
Reference in New Issue
Block a user