package web_test // A transcript produced by the cloud fallback means this recording's audio left the // homelab, which the reader is told in plain words (#52). "Local" is config.IsLocalModel: // one definition, not a second string match in the view. import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func setEndpoint(t *testing.T, id, endpoint string) { t.Helper() _, err := rawPool(t).Exec(context.Background(), `UPDATE uploaded_transcripts SET endpoint = $2 WHERE id = $1`, id, endpoint) require.NoError(t, err) } func TestUploadStatus_ACloudServedTranscriptSaysTheAudioLeftTheHomelab(t *testing.T) { app, _ := newUploadApp(t, audioOK, 200<<20) id := seedUpload(t, userID, "m", "done", "Synthetic transcript text.") setEndpoint(t, id, "berget/kb-whisper") b := body(t, do(t, app, get("/uploads/"+id+"/status"))) assert.Contains(t, b, "left the homelab") assert.Contains(t, b, "cloud service (berget)") } func TestUploadStatus_ALocallyServedTranscriptCarriesNoCloudNote(t *testing.T) { for _, endpoint := range []string{"iguana/kb-whisper", "koala/whisper", ""} { t.Run(endpoint, func(t *testing.T) { app, _ := newUploadApp(t, audioOK, 200<<20) id := seedUpload(t, userID, "m", "done", "Synthetic transcript text.") setEndpoint(t, id, endpoint) b := body(t, do(t, app, get("/uploads/"+id+"/status"))) assert.NotContains(t, b, "left the homelab") }) } } func TestUploadStatus_AnEndpointThatOnlyLooksLocalIsStillNamedAsCloud(t *testing.T) { // The prefix alone must not decide it: IsLocalModel refuses path tricks. app, _ := newUploadApp(t, audioOK, 200<<20) id := seedUpload(t, userID, "m", "done", "Synthetic transcript text.") setEndpoint(t, id, "iguana/../berget/kb-whisper") b := body(t, do(t, app, get("/uploads/"+id+"/status"))) assert.Contains(t, b, "left the homelab") } // The two-engine path (ADR-034) writes one composite endpoint string. Every name in it is // a local model, so the audio never left the homelab and the note must not say it did. func TestUploadStatus_AReconciledAllLocalEndpointCarriesNoCloudNote(t *testing.T) { for _, endpoint := range []string{ "iguana/kb-whisper + koala/whisper, reconciled by iguana/gemma4-26b", "iguana/kb-whisper + koala/whisper, reconciled by iguana/gemma4-26b\n", } { t.Run(endpoint, func(t *testing.T) { app, _ := newUploadApp(t, audioOK, 200<<20) id := seedUpload(t, userID, "m", "done", "Synthetic transcript text.") setEndpoint(t, id, endpoint) b := body(t, do(t, app, get("/uploads/"+id+"/status"))) assert.NotContains(t, b, "left the homelab") }) } } func TestUploadStatus_AReconciledEndpointNamingACloudEngineStillNamesTheCloudProvider(t *testing.T) { app, _ := newUploadApp(t, audioOK, 200<<20) id := seedUpload(t, userID, "m", "done", "Synthetic transcript text.") setEndpoint(t, id, "iguana/kb-whisper + berget/kb-whisper, reconciled by iguana/gemma4-26b") b := body(t, do(t, app, get("/uploads/"+id+"/status"))) assert.Contains(t, b, "cloud service (berget)") } // An alias without a provider prefix is not a local model, wherever it sits in the // composite: it must never be dropped from the judgement (PR #58 re-review). func TestUploadStatus_AReconciledEndpointWithAnUnprefixedAliasIsNotCalledLocal(t *testing.T) { for _, endpoint := range []string{ "iguana/kb-whisper + whisper-1, reconciled by iguana/gemma4-26b", "iguana/kb-whisper + whisper 1, reconciled by iguana/gemma4-26b", "iguana/kb-whisper + berget / x, reconciled by iguana/gemma4-26b", } { t.Run(endpoint, func(t *testing.T) { app, _ := newUploadApp(t, audioOK, 200<<20) id := seedUpload(t, userID, "m", "done", "Synthetic transcript text.") setEndpoint(t, id, endpoint) b := body(t, do(t, app, get("/uploads/"+id+"/status"))) assert.Contains(t, b, "left the homelab") assert.NotContains(t, b, "cloud service ()", "the note names a provider") }) } }