From 4301e691f5ba1dee324e6afe8da23de6618d8b5f Mon Sep 17 00:00:00 2001 From: Mathias Date: Sat, 3 Oct 2026 21:02:16 +0200 Subject: [PATCH] test(web): a cloud-served transcript says the audio left the homelab (#52), red Co-Authored-By: Claude Sonnet 5.5 --- internal/web/uploads_cloud_note_test.go | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 internal/web/uploads_cloud_note_test.go diff --git a/internal/web/uploads_cloud_note_test.go b/internal/web/uploads_cloud_note_test.go new file mode 100644 index 0000000..f6ebf76 --- /dev/null +++ b/internal/web/uploads_cloud_note_test.go @@ -0,0 +1,55 @@ +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") +}