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:
2026-04-22 10:51:33 +02:00
parent f438e972d4
commit af3377a6bc
21 changed files with 374 additions and 793 deletions
+1 -3
View File
@@ -129,9 +129,7 @@ impl TestConfig {
/// `Config::test_default` themselves are broken (not reachable in
/// practice).
pub fn build(self) -> Arc<Config> {
let data_path = self
.data_path
.unwrap_or_else(|| unique_tmpdir(self.label));
let data_path = self.data_path.unwrap_or_else(|| unique_tmpdir(self.label));
let api_keys: HashMap<String, String> = self
.users
.iter()
+1 -5
View File
@@ -121,11 +121,7 @@ pub fn header_str(response: &Response, name: &str) -> String {
/// Uses the server's canonical field names (`case_id`, `recorded_at`,
/// `audio`) from `doctate_common::constants`, so a server-side rename
/// propagates here for free.
pub fn multipart_upload_body(
case_id: &str,
recorded_at: &str,
audio: &[u8],
) -> (String, Vec<u8>) {
pub fn multipart_upload_body(case_id: &str, recorded_at: &str, audio: &[u8]) -> (String, Vec<u8>) {
let boundary = "----testboundary";
let mut body = Vec::new();
+1 -1
View File
@@ -26,7 +26,7 @@ pub mod users;
// Re-exports for ergonomic `use common::*;` in most test files.
pub use config::{TestConfig, unique_tmpdir};
pub use http::{
body_json, body_string, csrf_form_post, form_post, get_with_api_key,
body_bytes, body_json, body_string, csrf_form_post, form_post, get_with_api_key,
get_with_api_key_if_none_match, get_with_cookie, header_opt, header_str, multipart_upload_body,
};
pub use seed::{
+1 -5
View File
@@ -40,11 +40,7 @@ pub fn seed_recording(case_dir: &Path, stem: &str, transcript: Option<&str>) ->
/// Like [`seed_recording`] but additionally writes the `.duration.txt`
/// sidecar — used by the delete-recording tests that assert every
/// sidecar is cleaned up.
pub fn seed_recording_with_sidecars(
case_dir: &Path,
stem: &str,
transcript: &str,
) -> String {
pub fn seed_recording_with_sidecars(case_dir: &Path, stem: &str, transcript: &str) -> String {
let filename = seed_recording(case_dir, stem, Some(transcript));
std::fs::write(case_dir.join(format!("{stem}.duration.txt")), "42").unwrap();
filename
+1 -5
View File
@@ -58,11 +58,7 @@ pub fn test_user_with_password(slug: &str, password: &str) -> User {
/// Doctor user with custom retention settings — for the retention sweep
/// tests that drive the lazy auto-close / auto-purge logic.
pub fn test_user_with_retention(
slug: &str,
auto_close_days: u32,
auto_delete_days: u32,
) -> User {
pub fn test_user_with_retention(slug: &str, auto_close_days: u32, auto_delete_days: u32) -> User {
let mut u = test_user(slug);
u.retention = RetentionUserSettings {
auto_close_days,