refactor(server): plumb Arc<Settings> through workers and routes
Config sheds its 14 Bucket-B fields (retention, whisper, ollama, llm) and gains a sibling Arc<Settings> in AppState, loaded from settings.toml at startup via Settings::load_or_default. Workers (transcribe, analyze, recovery, auto_trigger) and routes (health, bulk, case_actions, user_web) take settings as a separate parameter or State<> extractor; Config::llm_configured moves to Settings::llm_configured. TestConfig::build_pair() returns (Arc<Config>, Arc<Settings>); the new create_router_with_settings / create_router_and_session_store_with_settings helpers wire both into integration tests that exercise LLM/Whisper/Ollama. The legacy single-Arc create_router falls back to Settings::default() so the 17 non-LLM tests stay untouched. Verified: cargo build clean, clippy --all-targets clean, 318 tests pass.
This commit is contained in:
@@ -23,27 +23,32 @@ use common::{
|
||||
// Fixture helpers
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
fn cfg_llm(label: &'static str) -> std::sync::Arc<doctate_server::config::Config> {
|
||||
type CfgPair = (
|
||||
std::sync::Arc<doctate_server::config::Config>,
|
||||
std::sync::Arc<doctate_server::settings::Settings>,
|
||||
);
|
||||
|
||||
fn cfg_llm(label: &'static str) -> CfgPair {
|
||||
TestConfig::new()
|
||||
.with_label(label)
|
||||
.with_user(test_user("dr_a"))
|
||||
.with_llm("http://unused")
|
||||
.build()
|
||||
.build_pair()
|
||||
}
|
||||
|
||||
fn cfg_llm_admin(label: &'static str) -> std::sync::Arc<doctate_server::config::Config> {
|
||||
fn cfg_llm_admin(label: &'static str) -> CfgPair {
|
||||
TestConfig::new()
|
||||
.with_label(label)
|
||||
.with_user(test_admin("dr_a"))
|
||||
.with_llm("http://unused")
|
||||
.build()
|
||||
.build_pair()
|
||||
}
|
||||
|
||||
fn cfg_without_llm(label: &'static str) -> std::sync::Arc<doctate_server::config::Config> {
|
||||
fn cfg_without_llm(label: &'static str) -> CfgPair {
|
||||
TestConfig::new()
|
||||
.with_label(label)
|
||||
.with_user(test_user("dr_a"))
|
||||
.build()
|
||||
.build_pair()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -52,8 +57,8 @@ fn cfg_without_llm(label: &'static str) -> std::sync::Arc<doctate_server::config
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_without_cookie_redirects_to_login() {
|
||||
let cfg = cfg_llm("a");
|
||||
let app = doctate_server::create_router(cfg);
|
||||
let (cfg, settings) = cfg_llm("a");
|
||||
let app = doctate_server::create_router_with_settings(cfg, settings);
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let resp = app
|
||||
.oneshot(
|
||||
@@ -70,14 +75,14 @@ async fn analyze_without_cookie_redirects_to_login() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_foreign_case_returns_404() {
|
||||
let cfg = cfg_llm("b");
|
||||
let (cfg, settings) = cfg_llm("b");
|
||||
// Seed a case owned by someone else.
|
||||
let foreign_case = "22222222-2222-2222-2222-222222222222";
|
||||
let foreign_dir = cfg.data_path.join("dr_other").join(foreign_case);
|
||||
std::fs::create_dir_all(&foreign_dir).unwrap();
|
||||
seed_recording(&foreign_dir, "2026-04-15T10-00-00Z", Some("text"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -94,8 +99,8 @@ async fn analyze_foreign_case_returns_404() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_invalid_uuid_returns_400() {
|
||||
let cfg = cfg_llm("c");
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (cfg, settings) = cfg_llm("c");
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -112,12 +117,12 @@ async fn analyze_invalid_uuid_returns_400() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_case_without_recordings_returns_400() {
|
||||
let cfg = cfg_llm("d");
|
||||
let (cfg, settings) = cfg_llm("d");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
// No .m4a files.
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -134,13 +139,13 @@ async fn analyze_case_without_recordings_returns_400() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_case_with_missing_transcript_returns_400() {
|
||||
let cfg = cfg_llm("e");
|
||||
let (cfg, settings) = cfg_llm("e");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
seed_recording(&case_dir, "2026-04-15T10-05-00Z", None); // still transcribing
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -157,12 +162,12 @@ async fn analyze_case_with_missing_transcript_returns_400() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_case_without_llm_returns_503() {
|
||||
let cfg = cfg_without_llm("f");
|
||||
let (cfg, settings) = cfg_without_llm("f");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -183,7 +188,7 @@ async fn analyze_case_without_llm_returns_503() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_case_happy_path_writes_input_and_redirects() {
|
||||
let cfg = cfg_llm("g");
|
||||
let (cfg, settings) = cfg_llm("g");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(
|
||||
@@ -197,7 +202,7 @@ async fn analyze_case_happy_path_writes_input_and_redirects() {
|
||||
Some("Korrektur: links, nicht rechts."),
|
||||
);
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -234,12 +239,12 @@ async fn analyze_case_happy_path_writes_input_and_redirects() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_case_second_time_returns_409() {
|
||||
let cfg = cfg_llm("h");
|
||||
let (cfg, settings) = cfg_llm("h");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("text"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let first = app
|
||||
@@ -268,14 +273,14 @@ async fn analyze_case_second_time_returns_409() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_case_skips_blank_transcript_from_recordings() {
|
||||
let cfg = cfg_llm("i");
|
||||
let (cfg, settings) = cfg_llm("i");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("echt"));
|
||||
seed_recording(&case_dir, "2026-04-15T10-05-00Z", Some(" ")); // blank
|
||||
seed_recording(&case_dir, "2026-04-15T10-10-00Z", Some("auch echt"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -328,12 +333,12 @@ async fn analyze_worker_writes_document_via_wiremock() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let cfg = TestConfig::new()
|
||||
let (_cfg, settings) = TestConfig::new()
|
||||
.with_label("analyze-w")
|
||||
.with_data_path(tmp.clone())
|
||||
.with_user(test_user("dr_a"))
|
||||
.with_llm(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let (tx, rx) = analyze::channel();
|
||||
let client = reqwest::Client::new();
|
||||
@@ -341,7 +346,7 @@ async fn analyze_worker_writes_document_via_wiremock() {
|
||||
let vocab = Arc::new(doctate_server::gazetteer::Gazetteer::empty());
|
||||
let handle = tokio::spawn(analyze::worker::run(
|
||||
rx,
|
||||
cfg,
|
||||
settings,
|
||||
client,
|
||||
busy,
|
||||
vocab,
|
||||
@@ -420,19 +425,19 @@ async fn analyze_worker_normalizes_llm_output() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let cfg = TestConfig::new()
|
||||
let (_cfg, settings) = TestConfig::new()
|
||||
.with_label("analyze-gaz")
|
||||
.with_data_path(tmp.clone())
|
||||
.with_user(test_user("dr_a"))
|
||||
.with_llm(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let (tx, rx) = analyze::channel();
|
||||
let client = reqwest::Client::new();
|
||||
let busy = Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
let handle = tokio::spawn(analyze::worker::run(
|
||||
rx,
|
||||
cfg,
|
||||
settings,
|
||||
client,
|
||||
busy,
|
||||
vocab,
|
||||
@@ -553,14 +558,14 @@ async fn recovery_skips_completed_analysis() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn analyze_deletes_old_document_and_writes_fresh_input() {
|
||||
let cfg = cfg_llm("rn-5");
|
||||
let (cfg, settings) = cfg_llm("rn-5");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
std::fs::write(case_dir.join(DOCUMENT_FILE), "altes Dokument").unwrap();
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("erste Aufnahme"));
|
||||
seed_recording(&case_dir, "2026-04-15T10-05-00Z", Some("zweite Aufnahme"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -591,12 +596,12 @@ async fn analyze_deletes_old_document_and_writes_fresh_input() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn close_writes_marker_and_hides_case() {
|
||||
let cfg = cfg_llm("close-1");
|
||||
let (cfg, settings) = cfg_llm("close-1");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -629,12 +634,12 @@ async fn close_writes_marker_and_hides_case() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn closed_case_returns_404_on_detail() {
|
||||
let cfg = cfg_llm("close-2");
|
||||
let (cfg, settings) = cfg_llm("close-2");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -658,12 +663,12 @@ async fn closed_case_returns_404_on_detail() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn reopen_removes_marker_and_restores_case() {
|
||||
let cfg = cfg_llm("reopen-1");
|
||||
let (cfg, settings) = cfg_llm("reopen-1");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
// Close, then reopen via the explicit endpoint.
|
||||
@@ -705,12 +710,12 @@ async fn reopen_removes_marker_and_restores_case() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn show_closed_query_includes_closed_cases() {
|
||||
let cfg = cfg_llm("show-closed");
|
||||
let (cfg, settings) = cfg_llm("show-closed");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("a closed one"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
// Close first.
|
||||
@@ -761,12 +766,12 @@ async fn show_closed_query_includes_closed_cases() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn closed_case_detail_with_show_closed_returns_200() {
|
||||
let cfg = cfg_llm("show-detail");
|
||||
let (cfg, settings) = cfg_llm("show-detail");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("x"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let _ = app
|
||||
@@ -804,12 +809,12 @@ async fn closed_case_detail_with_show_closed_returns_200() {
|
||||
async fn close_redirects_back_to_referer_query() {
|
||||
// Close from the show-closed listing must keep ?show_closed=1 so
|
||||
// the user stays in the view they were in.
|
||||
let cfg = cfg_llm("close-ref-q");
|
||||
let (cfg, settings) = cfg_llm("close-ref-q");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let mut req = csrf_form_post(paths::case_close(case_id), &cookie, &csrf, "");
|
||||
@@ -833,12 +838,12 @@ async fn close_from_detail_redirects_to_list_preserving_query() {
|
||||
// Close from /web/cases/{uuid}?show_closed=1 must NOT redirect back
|
||||
// to the detail page (it 404s after the close). The uuid segment
|
||||
// is stripped; the query survives so the user lands in show-closed.
|
||||
let cfg = cfg_llm("close-ref-det");
|
||||
let (cfg, settings) = cfg_llm("close-ref-det");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let mut req = csrf_form_post(paths::case_close(case_id), &cookie, &csrf, "");
|
||||
@@ -866,12 +871,12 @@ async fn reopen_redirects_back_to_referer() {
|
||||
// User reopens a case from the show-closed listing. The redirect
|
||||
// must preserve `?show_closed=1` so the user stays in that view
|
||||
// instead of being ejected back to the default open-only listing.
|
||||
let cfg = cfg_llm("reopen-ref");
|
||||
let (cfg, settings) = cfg_llm("reopen-ref");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let _ = app
|
||||
@@ -903,12 +908,12 @@ async fn reopen_redirects_back_to_referer() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn reopen_is_noop_on_open_case() {
|
||||
let cfg = cfg_llm("reopen-2");
|
||||
let (cfg, settings) = cfg_llm("reopen-2");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -927,12 +932,12 @@ async fn reopen_is_noop_on_open_case() {
|
||||
#[tokio::test]
|
||||
async fn purge_closed_removes_directory() {
|
||||
// purge-closed is admin-only (matches the UI, which hides the bar).
|
||||
let cfg = cfg_llm_admin("purge-1");
|
||||
let (cfg, settings) = cfg_llm_admin("purge-1");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let _ = app
|
||||
@@ -965,12 +970,12 @@ async fn purge_closed_removes_directory() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn purge_requires_confirm_param() {
|
||||
let cfg = cfg_llm_admin("purge-2");
|
||||
let (cfg, settings) = cfg_llm_admin("purge-2");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let _ = app
|
||||
@@ -998,7 +1003,7 @@ async fn purge_requires_confirm_param() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn purge_closed_keeps_open_cases() {
|
||||
let cfg = cfg_llm_admin("purge-3");
|
||||
let (cfg, settings) = cfg_llm_admin("purge-3");
|
||||
let closed_id = "11111111-1111-1111-1111-111111111111";
|
||||
let open_id = "22222222-2222-2222-2222-222222222222";
|
||||
let dir_closed = seed_case(&cfg.data_path, "dr_a", closed_id);
|
||||
@@ -1006,7 +1011,7 @@ async fn purge_closed_keeps_open_cases() {
|
||||
seed_recording(&dir_closed, "2026-04-15T10-00-00Z", Some("a"));
|
||||
seed_recording(&dir_open, "2026-04-15T10-00-00Z", Some("b"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let _ = app
|
||||
@@ -1040,12 +1045,12 @@ async fn purge_closed_keeps_open_cases() {
|
||||
#[tokio::test]
|
||||
async fn purge_closed_rejected_for_non_admin() {
|
||||
// Default `test_user` is role=doctor.
|
||||
let cfg = cfg_llm("purge-nonadmin");
|
||||
let (cfg, settings) = cfg_llm("purge-nonadmin");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&case_dir, "2026-04-15T10-00-00Z", Some("ok"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
// Close the case first so there is something for purge to target.
|
||||
@@ -1077,7 +1082,7 @@ async fn purge_closed_rejected_for_non_admin() {
|
||||
async fn bulk_close_shares_one_closed_at_timestamp() {
|
||||
// Bulk actions are admin-only since the UI hides the selection
|
||||
// from non-admins; the handler enforces the same gate.
|
||||
let cfg = cfg_llm_admin("bulk-c");
|
||||
let (cfg, settings) = cfg_llm_admin("bulk-c");
|
||||
let case_a = "11111111-1111-1111-1111-111111111111";
|
||||
let case_b = "22222222-2222-2222-2222-222222222222";
|
||||
let dir_a = seed_case(&cfg.data_path, "dr_a", case_a);
|
||||
@@ -1085,7 +1090,7 @@ async fn bulk_close_shares_one_closed_at_timestamp() {
|
||||
seed_recording(&dir_a, "2026-04-15T10-00-00Z", Some("a"));
|
||||
seed_recording(&dir_b, "2026-04-15T10-05-00Z", Some("b"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let body = format!(
|
||||
@@ -1111,7 +1116,7 @@ async fn bulk_close_shares_one_closed_at_timestamp() {
|
||||
#[tokio::test]
|
||||
async fn bulk_analyze_processes_each_selected_case() {
|
||||
// Bulk analyze is admin-only (UI + handler).
|
||||
let cfg = cfg_llm_admin("bulk-a");
|
||||
let (cfg, settings) = cfg_llm_admin("bulk-a");
|
||||
let case_a = "11111111-1111-1111-1111-111111111111";
|
||||
let case_b = "22222222-2222-2222-2222-222222222222";
|
||||
let dir_a = seed_case(&cfg.data_path, "dr_a", case_a);
|
||||
@@ -1119,7 +1124,7 @@ async fn bulk_analyze_processes_each_selected_case() {
|
||||
seed_recording(&dir_a, "2026-04-15T10-00-00Z", Some("a"));
|
||||
seed_recording(&dir_b, "2026-04-15T10-05-00Z", Some("b"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let body = format!(
|
||||
@@ -1160,7 +1165,7 @@ async fn recovery_skips_closed_cases() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn reset_case_clears_derived_and_unfails_audio() {
|
||||
let cfg = cfg_llm_admin("reset-admin");
|
||||
let (cfg, settings) = cfg_llm_admin("reset-admin");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
|
||||
@@ -1177,7 +1182,7 @@ async fn reset_case_clears_derived_and_unfails_audio() {
|
||||
std::fs::write(dir.join(DOCUMENT_FILE), "# Doc\n").unwrap();
|
||||
std::fs::write(dir.join(ANALYSIS_INPUT_FILE), "{}").unwrap();
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -1209,13 +1214,13 @@ async fn reset_case_clears_derived_and_unfails_audio() {
|
||||
#[tokio::test]
|
||||
async fn reset_case_requires_admin() {
|
||||
// Default `test_user` has role=doctor, not admin.
|
||||
let cfg = cfg_llm("reset-nonadmin");
|
||||
let (cfg, settings) = cfg_llm("reset-nonadmin");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&dir, "2026-04-15T09-00-00Z", Some("hallo"));
|
||||
std::fs::write(dir.join(DOCUMENT_FILE), "# Doc\n").unwrap();
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let resp = app
|
||||
@@ -1236,12 +1241,12 @@ async fn reset_case_requires_admin() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn bulk_reset_processes_multiple_cases_admin_only() {
|
||||
let cfg = TestConfig::new()
|
||||
let (cfg, settings) = TestConfig::new()
|
||||
.with_label("bulk-reset")
|
||||
.with_user(test_admin("dr_a"))
|
||||
.with_user(test_user("dr_b"))
|
||||
.with_llm("http://unused")
|
||||
.build();
|
||||
.build_pair();
|
||||
let case_a = "11111111-1111-1111-1111-111111111111";
|
||||
let case_b = "22222222-2222-2222-2222-222222222222";
|
||||
let dir_a = seed_case(&cfg.data_path, "dr_a", case_a);
|
||||
@@ -1256,7 +1261,7 @@ async fn bulk_reset_processes_multiple_cases_admin_only() {
|
||||
seed_recording(&dir_c, "2026-04-15T11-00-00Z", Some("c"));
|
||||
std::fs::write(dir_c.join(DOCUMENT_FILE), "C").unwrap();
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
|
||||
// Admin: bulk reset succeeds.
|
||||
let (cookie_admin, csrf_admin) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
@@ -1304,12 +1309,12 @@ async fn bulk_reset_processes_multiple_cases_admin_only() {
|
||||
#[tokio::test]
|
||||
async fn bulk_close_rejected_for_non_admin() {
|
||||
// Default `test_user` is role=doctor.
|
||||
let cfg = cfg_llm("bulk-close-nonadmin");
|
||||
let (cfg, settings) = cfg_llm("bulk-close-nonadmin");
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(&dir, "2026-04-15T10-00-00Z", Some("a"));
|
||||
|
||||
let (app, store) = doctate_server::create_router_and_session_store(cfg);
|
||||
let (app, store) = doctate_server::create_router_and_session_store_with_settings(cfg, settings);
|
||||
let (cookie, csrf) = login_with_csrf(&app, &store, "dr_a", "s").await;
|
||||
|
||||
let body = format!("action={}&case_id={case_id}", BulkAction::Close);
|
||||
@@ -1370,12 +1375,12 @@ async fn analyze_works_against_ollama_style_endpoint_without_api_key() {
|
||||
// Ollama-style config: explicitly empty api_key — `with_llm_explicit`
|
||||
// lets the builder carry "" through, whereas `with_llm` would default
|
||||
// to the hosted-provider test key.
|
||||
let cfg = TestConfig::new()
|
||||
let (_cfg, settings) = TestConfig::new()
|
||||
.with_label("analyze-ollama")
|
||||
.with_data_path(tmp.clone())
|
||||
.with_user(test_user("dr_a"))
|
||||
.with_llm_explicit(mock.uri(), "", "llama3.3:70b")
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let (tx, rx) = analyze::channel();
|
||||
let client = reqwest::Client::new();
|
||||
@@ -1383,7 +1388,7 @@ async fn analyze_works_against_ollama_style_endpoint_without_api_key() {
|
||||
let vocab = Arc::new(doctate_server::gazetteer::Gazetteer::empty());
|
||||
let handle = tokio::spawn(analyze::worker::run(
|
||||
rx,
|
||||
cfg,
|
||||
settings,
|
||||
client,
|
||||
busy,
|
||||
vocab,
|
||||
|
||||
@@ -77,11 +77,11 @@ async fn case_page_document_has_copy_button() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn case_page_shows_analyze_button_when_transcribed_without_document() {
|
||||
let cfg = TestConfig::new()
|
||||
let (cfg, settings) = TestConfig::new()
|
||||
.with_label("cp-analyze")
|
||||
.with_user(test_user("dr_a"))
|
||||
.with_llm("http://unused")
|
||||
.build();
|
||||
.build_pair();
|
||||
let case_id = "11111111-1111-1111-1111-111111111111";
|
||||
let case_dir = seed_case(&cfg.data_path, "dr_a", case_id);
|
||||
seed_recording(
|
||||
@@ -90,7 +90,7 @@ async fn case_page_shows_analyze_button_when_transcribed_without_document() {
|
||||
Some("transkribierter Text"),
|
||||
);
|
||||
|
||||
let app = doctate_server::create_router(cfg);
|
||||
let app = doctate_server::create_router_with_settings(cfg, settings);
|
||||
let cookie = login_dr_a(&app).await;
|
||||
|
||||
let resp = app
|
||||
|
||||
@@ -11,6 +11,7 @@ use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use doctate_server::config::{Config, User};
|
||||
use doctate_server::settings::Settings;
|
||||
|
||||
/// Unique tempdir path for a given label. `process::id()` + UUID v4
|
||||
/// keeps parallel `cargo test` runs from colliding; the label lets
|
||||
@@ -125,10 +126,17 @@ impl TestConfig {
|
||||
self
|
||||
}
|
||||
|
||||
/// Materialize the config. Panics only if the workspace-defaults in
|
||||
/// `Config::test_default` themselves are broken (not reachable in
|
||||
/// practice).
|
||||
/// Materialize the config alone. Bucket-B overrides (`with_llm`,
|
||||
/// `with_whisper`, `with_ollama`) are silently dropped — call
|
||||
/// [`build_pair`] when those need to take effect.
|
||||
pub fn build(self) -> Arc<Config> {
|
||||
self.build_pair().0
|
||||
}
|
||||
|
||||
/// Materialize both `Config` and `Settings`. Use when a test exercises
|
||||
/// LLM, Whisper or Ollama paths and needs the builder-set values to
|
||||
/// reach the worker.
|
||||
pub fn build_pair(self) -> (Arc<Config>, Arc<Settings>) {
|
||||
let data_path = self.data_path.unwrap_or_else(|| unique_tmpdir(self.label));
|
||||
let api_keys: HashMap<String, String> = self
|
||||
.users
|
||||
@@ -136,21 +144,33 @@ impl TestConfig {
|
||||
.map(|u| (u.api_key.clone(), u.slug.clone()))
|
||||
.collect();
|
||||
|
||||
let defaults = Config::test_default();
|
||||
Arc::new(Config {
|
||||
let config = Arc::new(Config {
|
||||
data_path,
|
||||
users: self.users,
|
||||
api_keys,
|
||||
llm_url: self.llm_url.unwrap_or(defaults.llm_url),
|
||||
llm_api_key: self.llm_api_key.unwrap_or(defaults.llm_api_key),
|
||||
llm_model: self.llm_model.unwrap_or(defaults.llm_model),
|
||||
whisper_url: self.whisper_url.unwrap_or(defaults.whisper_url),
|
||||
whisper_timeout_seconds: self
|
||||
.whisper_timeout_seconds
|
||||
.unwrap_or(defaults.whisper_timeout_seconds),
|
||||
ollama_url: self.ollama_url.unwrap_or(defaults.ollama_url),
|
||||
..Config::test_default()
|
||||
})
|
||||
});
|
||||
|
||||
let mut settings = Settings::default();
|
||||
if let Some(v) = self.llm_url {
|
||||
settings.llm.url = v;
|
||||
}
|
||||
if let Some(v) = self.llm_api_key {
|
||||
settings.llm.api_key = v;
|
||||
}
|
||||
if let Some(v) = self.llm_model {
|
||||
settings.llm.model = v;
|
||||
}
|
||||
if let Some(v) = self.whisper_url {
|
||||
settings.whisper.url = v;
|
||||
}
|
||||
if let Some(v) = self.whisper_timeout_seconds {
|
||||
settings.whisper.timeout_seconds = v;
|
||||
}
|
||||
if let Some(v) = self.ollama_url {
|
||||
settings.ollama.url = v;
|
||||
}
|
||||
(config, Arc::new(settings))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ async fn failed_only_case_settles_to_empty_without_llm_call() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let config = TestConfig::new()
|
||||
let (_config, settings) = TestConfig::new()
|
||||
.with_data_path(data.path().to_path_buf())
|
||||
.with_ollama(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let vocab = Arc::new(Gazetteer::empty());
|
||||
let events_tx = events::channel();
|
||||
@@ -75,7 +75,14 @@ async fn failed_only_case_settles_to_empty_without_llm_call() {
|
||||
};
|
||||
|
||||
pipeline
|
||||
.heal_orphans_if_idle(&user_root, slug, &http_client, &config, &vocab, &events_tx)
|
||||
.heal_orphans_if_idle(
|
||||
&user_root,
|
||||
slug,
|
||||
&http_client,
|
||||
&settings,
|
||||
&vocab,
|
||||
&events_tx,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Heal spawn drops the busy flag on completion — poll until idle.
|
||||
|
||||
@@ -59,6 +59,7 @@ fn build_state_with_stores() -> AppState {
|
||||
let (analyze_tx, _analyze_rx) = analyze::channel();
|
||||
AppState {
|
||||
config: cfg,
|
||||
settings: Arc::new(doctate_server::settings::Settings::default()),
|
||||
transcribe_tx,
|
||||
analyze_tx,
|
||||
session_store: web_session::new_store(),
|
||||
|
||||
@@ -71,10 +71,10 @@ async fn heal_orphans_returns_fast_and_dedups_parallel_calls() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let config = TestConfig::new()
|
||||
let (_config, settings) = TestConfig::new()
|
||||
.with_data_path(data.path().to_path_buf())
|
||||
.with_ollama(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let vocab = Arc::new(Gazetteer::empty());
|
||||
let events_tx = events::channel();
|
||||
@@ -99,10 +99,24 @@ async fn heal_orphans_returns_fast_and_dedups_parallel_calls() {
|
||||
let before = Instant::now();
|
||||
timeout(Duration::from_millis(150), async {
|
||||
pipeline
|
||||
.heal_orphans_if_idle(&user_root, slug, &http_client, &config, &vocab, &events_tx)
|
||||
.heal_orphans_if_idle(
|
||||
&user_root,
|
||||
slug,
|
||||
&http_client,
|
||||
&settings,
|
||||
&vocab,
|
||||
&events_tx,
|
||||
)
|
||||
.await;
|
||||
pipeline
|
||||
.heal_orphans_if_idle(&user_root, slug, &http_client, &config, &vocab, &events_tx)
|
||||
.heal_orphans_if_idle(
|
||||
&user_root,
|
||||
slug,
|
||||
&http_client,
|
||||
&settings,
|
||||
&vocab,
|
||||
&events_tx,
|
||||
)
|
||||
.await;
|
||||
})
|
||||
.await
|
||||
|
||||
@@ -72,6 +72,7 @@ fn build_app_with_events_tx(
|
||||
let (analyze_tx, _analyze_rx) = analyze::channel();
|
||||
AppState {
|
||||
config: cfg,
|
||||
settings: Arc::new(doctate_server::settings::Settings::default()),
|
||||
transcribe_tx,
|
||||
analyze_tx,
|
||||
session_store: web_session::new_store(),
|
||||
@@ -230,11 +231,11 @@ async fn early_latch_skips_llm_call_when_manual_set() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let cfg = TestConfig::new()
|
||||
let (cfg, settings) = TestConfig::new()
|
||||
.with_label("oneliner-override-early-latch")
|
||||
.with_user(test_user(SLUG))
|
||||
.with_ollama(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
let case_id = Uuid::new_v4().to_string();
|
||||
let case_dir = seed_case(&cfg.data_path, SLUG, &case_id);
|
||||
|
||||
@@ -263,7 +264,7 @@ async fn early_latch_skips_llm_call_when_manual_set() {
|
||||
&case_dir,
|
||||
SLUG,
|
||||
&reqwest::Client::new(),
|
||||
&cfg,
|
||||
&settings,
|
||||
&vocab,
|
||||
&events_tx,
|
||||
&locks,
|
||||
@@ -305,11 +306,11 @@ async fn re_check_drops_llm_result_when_manual_appears_during_regen() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let cfg = TestConfig::new()
|
||||
let (cfg, settings) = TestConfig::new()
|
||||
.with_label("oneliner-override-race")
|
||||
.with_user(test_user(SLUG))
|
||||
.with_ollama(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
let case_id = Uuid::new_v4().to_string();
|
||||
let case_dir = seed_case(&cfg.data_path, SLUG, &case_id);
|
||||
|
||||
@@ -326,7 +327,7 @@ async fn re_check_drops_llm_result_when_manual_appears_during_regen() {
|
||||
|
||||
// Spawn the regen — it will wait ~500ms inside Mock-Ollama before
|
||||
// reaching the re-check-under-lock branch.
|
||||
let regen_cfg = cfg.clone();
|
||||
let regen_settings = settings.clone();
|
||||
let regen_locks = locks.clone();
|
||||
let regen_events = events_tx.clone();
|
||||
let regen_dir = case_dir.clone();
|
||||
@@ -336,7 +337,7 @@ async fn re_check_drops_llm_result_when_manual_appears_during_regen() {
|
||||
®en_dir,
|
||||
SLUG,
|
||||
&reqwest::Client::new(),
|
||||
®en_cfg,
|
||||
®en_settings,
|
||||
&vocab,
|
||||
®en_events,
|
||||
®en_locks,
|
||||
|
||||
@@ -55,10 +55,10 @@ async fn silent_only_case_settles_to_empty_without_llm_call() {
|
||||
.mount(&mock)
|
||||
.await;
|
||||
|
||||
let config = TestConfig::new()
|
||||
let (_config, settings) = TestConfig::new()
|
||||
.with_data_path(data.path().to_path_buf())
|
||||
.with_ollama(mock.uri())
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let vocab = Arc::new(Gazetteer::empty());
|
||||
let events_tx = events::channel();
|
||||
@@ -77,7 +77,14 @@ async fn silent_only_case_settles_to_empty_without_llm_call() {
|
||||
};
|
||||
|
||||
pipeline
|
||||
.heal_orphans_if_idle(&user_root, slug, &http_client, &config, &vocab, &events_tx)
|
||||
.heal_orphans_if_idle(
|
||||
&user_root,
|
||||
slug,
|
||||
&http_client,
|
||||
&settings,
|
||||
&vocab,
|
||||
&events_tx,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Heal spawn drops the busy flag on completion — poll until idle.
|
||||
|
||||
@@ -260,7 +260,12 @@ async fn recovery_enqueues_only_pending_recordings() {
|
||||
|
||||
// -------------------- Worker: failure marker --------------------
|
||||
|
||||
fn config_with_whisper(whisper_url: String) -> std::sync::Arc<doctate_server::config::Config> {
|
||||
fn config_with_whisper(
|
||||
whisper_url: String,
|
||||
) -> (
|
||||
std::sync::Arc<doctate_server::config::Config>,
|
||||
std::sync::Arc<doctate_server::settings::Settings>,
|
||||
) {
|
||||
// Ollama URL is irrelevant — worker never reaches it in the failure path.
|
||||
// Port 1 is effectively unreachable, matching the historical intent.
|
||||
TestConfig::new()
|
||||
@@ -268,7 +273,7 @@ fn config_with_whisper(whisper_url: String) -> std::sync::Arc<doctate_server::co
|
||||
.with_user(test_user("dr_test"))
|
||||
.with_whisper(whisper_url, 5)
|
||||
.with_ollama("http://127.0.0.1:1")
|
||||
.build()
|
||||
.build_pair()
|
||||
}
|
||||
|
||||
/// Permanent Whisper errors (4xx other than 408/429) must rename `.m4a` to
|
||||
@@ -292,7 +297,7 @@ async fn worker_renames_audio_to_failed_on_permanent_whisper_error() {
|
||||
let audio = case_dir.join("2026-04-13T10-30-00Z.m4a");
|
||||
std::fs::copy(fixture("sample.m4a"), &audio).unwrap();
|
||||
|
||||
let config = config_with_whisper(server.uri());
|
||||
let (config, settings) = config_with_whisper(server.uri());
|
||||
let (tx, rx) = transcribe::channel();
|
||||
tx.send(transcribe::TranscribeJob {
|
||||
audio_path: audio.clone(),
|
||||
@@ -308,6 +313,7 @@ async fn worker_renames_audio_to_failed_on_permanent_whisper_error() {
|
||||
transcribe::worker::run(
|
||||
rx,
|
||||
config,
|
||||
settings,
|
||||
client,
|
||||
busy,
|
||||
vocab,
|
||||
@@ -341,7 +347,7 @@ async fn worker_leaves_m4a_intact_on_transient_whisper_error() {
|
||||
let audio = case_dir.join("2026-04-13T10-31-00Z.m4a");
|
||||
std::fs::copy(fixture("sample.m4a"), &audio).unwrap();
|
||||
|
||||
let config = config_with_whisper(server.uri());
|
||||
let (config, settings) = config_with_whisper(server.uri());
|
||||
let (tx, rx) = transcribe::channel();
|
||||
tx.send(transcribe::TranscribeJob {
|
||||
audio_path: audio.clone(),
|
||||
@@ -357,6 +363,7 @@ async fn worker_leaves_m4a_intact_on_transient_whisper_error() {
|
||||
transcribe::worker::run(
|
||||
rx,
|
||||
config,
|
||||
settings,
|
||||
client,
|
||||
busy,
|
||||
vocab,
|
||||
@@ -407,7 +414,7 @@ async fn transcribe_worker_normalizes_whisper_output() {
|
||||
);
|
||||
assert_eq!(vocab.len(), 1);
|
||||
|
||||
let config = config_with_whisper(server.uri());
|
||||
let (config, settings) = config_with_whisper(server.uri());
|
||||
let (tx, rx) = transcribe::channel();
|
||||
tx.send(transcribe::TranscribeJob {
|
||||
audio_path: audio.clone(),
|
||||
@@ -422,6 +429,7 @@ async fn transcribe_worker_normalizes_whisper_output() {
|
||||
transcribe::worker::run(
|
||||
rx,
|
||||
config,
|
||||
settings,
|
||||
client,
|
||||
busy,
|
||||
vocab,
|
||||
|
||||
@@ -67,11 +67,11 @@ async fn transient_whisper_failure_is_reenqueued_and_recovers() {
|
||||
// Config points at the mock Whisper, ollama intentionally unreachable
|
||||
// (the oneliner heal may fire in parallel; we only assert on
|
||||
// the transcript artefact, not on the oneliner).
|
||||
let config = TestConfig::new()
|
||||
let (config, settings) = TestConfig::new()
|
||||
.with_data_path(data.path().to_path_buf())
|
||||
.with_user(test_user(slug))
|
||||
.with_whisper(whisper.uri(), 5)
|
||||
.build();
|
||||
.build_pair();
|
||||
|
||||
let vocab = Arc::new(Gazetteer::empty());
|
||||
let events_tx = events::channel();
|
||||
@@ -88,6 +88,7 @@ async fn transient_whisper_failure_is_reenqueued_and_recovers() {
|
||||
let worker = tokio::spawn(transcribe::worker::run(
|
||||
rx_t,
|
||||
config.clone(),
|
||||
settings.clone(),
|
||||
http_client.clone(),
|
||||
transcribe_busy.clone(),
|
||||
vocab.clone(),
|
||||
@@ -143,7 +144,14 @@ async fn transient_whisper_failure_is_reenqueued_and_recovers() {
|
||||
|
||||
// Act 2: heal re-enqueues the pending .m4a (second mock → 200).
|
||||
pipeline
|
||||
.heal_orphans_if_idle(&user_root, slug, &http_client, &config, &vocab, &events_tx)
|
||||
.heal_orphans_if_idle(
|
||||
&user_root,
|
||||
slug,
|
||||
&http_client,
|
||||
&settings,
|
||||
&vocab,
|
||||
&events_tx,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Assert: the transcript lands. Poll because the worker runs
|
||||
|
||||
Reference in New Issue
Block a user