From f704258fdf4ed3fd8a3febd952094ca299a97411 Mon Sep 17 00:00:00 2001 From: Mathias Date: Sun, 4 Oct 2026 22:48:29 +0200 Subject: [PATCH] test(transcribe): the wrapper does not restart a cancelled job; PlanFor of an empty or unknown language is pinned (#61) Low findings of the PR #62 re-review: the WithTimeout test's comment claimed cancellation travels on the context but only the language was asserted (the WithoutCancel mutant survived), and PlanFor('') and PlanFor(unknown) were untested. Co-Authored-By: Claude Sonnet 5.5 --- .../adapters/transcribe/ensemble_progress_test.go | 3 +++ internal/adapters/transcribe/timeout_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/adapters/transcribe/ensemble_progress_test.go b/internal/adapters/transcribe/ensemble_progress_test.go index 0a72aa1..caa0cbc 100644 --- a/internal/adapters/transcribe/ensemble_progress_test.go +++ b/internal/adapters/transcribe/ensemble_progress_test.go @@ -178,4 +178,7 @@ func TestEnsemblePlanFor_AnAutoLanguageListsOnlyThePhasesThatCanRun(t *testing.T assert.Equal(t, []string{"engine_b"}, keys(without.PlanFor(domain.LangAuto)), "no fallback configured: none promised") assert.Equal(t, with.Plan(), with.PlanFor(domain.LangSwedish), "Swedish is the plan it always was") assert.Contains(t, with.PlanFor(domain.LangAuto)[0].Label, "iguana/kb-whisper") + assert.Equal(t, with.Plan(), with.PlanFor(""), "a job queued before the choice existed is Swedish") + assert.Equal(t, with.PlanFor(domain.LangAuto), with.PlanFor(domain.Language("xx")), + "an unknown language is planned as it is run: not the Swedish phases") } diff --git a/internal/adapters/transcribe/timeout_test.go b/internal/adapters/transcribe/timeout_test.go index 1ec6205..7d03167 100644 --- a/internal/adapters/transcribe/timeout_test.go +++ b/internal/adapters/transcribe/timeout_test.go @@ -131,3 +131,16 @@ func TestWithTimeout_TheEngineStillReceivesTheLanguageOfTheJob(t *testing.T) { }) } } + +func TestWithTimeout_ACancelledJobIsNotRestartedByTheWrapper(t *testing.T) { + var got seen + srv := serve(t, 200, verboseJSON, &got) + b := transcribe.WithTimeout(transcribe.NewGateway(srv.URL+"/v1", "k", "iguana/kb-whisper", srv.Client()), time.Minute) + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + _, err := b.Transcribe(ctx, wavFile(t, "RIFF-synthetic-pcm")) + + require.Error(t, err) + assert.Empty(t, got.method, "a cancelled job must not send its audio anywhere through the wrapper") +}