diff --git a/internal/adapters/transcribe/ensemble_reason_test.go b/internal/adapters/transcribe/ensemble_reason_test.go new file mode 100644 index 0000000..4777bd7 --- /dev/null +++ b/internal/adapters/transcribe/ensemble_reason_test.go @@ -0,0 +1,36 @@ +package transcribe_test + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "git.d-ma.be/mathias/tapir/internal/adapters/transcribe" + "git.d-ma.be/mathias/tapir/internal/reconcile" +) + +// When one engine is down the page says so and why; the "why" is a kind, not the +// engine's error text, which can carry provider output (adversarial review F3). + +func TestEnsemble_AFailedEnginesReasonIsAKindNotItsErrorText(t *testing.T) { + r := newEnsemble("text", "text", nil, errors.New("kb-whisper said: zebrakaka secret words"), false, &verdictAdj{v: reconcile.VerdictAlt}) + + got, err := r.e.Transcribe(context.Background(), "/a.wav") + + require.NoError(t, err) + assert.NotContains(t, got.Reconciliation.Reason, "zebrakaka") + assert.Contains(t, got.Reconciliation.Reason, "iguana/kb-whisper failed", "which engine failed is still said") +} + +func TestEnsemble_AnHTTPFailureShowsItsStatusCodeAsTheKind(t *testing.T) { + r := newEnsemble("text", "text", &transcribe.StatusError{Code: 502, Snippet: "zebrakaka"}, nil, false, &verdictAdj{}) + + got, err := r.e.Transcribe(context.Background(), "/a.wav") + + require.NoError(t, err) + assert.Contains(t, got.Reconciliation.Reason, "http_502") + assert.NotContains(t, got.Reconciliation.Reason, "zebrakaka") +}