From 2227cfff7e034da7c9a5a944e308faae58ccce48 Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 1 Oct 2026 16:46:14 +0200 Subject: [PATCH] test(transcribe): opt-in live check against the real gateway The httptest fake proves only what we THINK the gateway accepts. Skipped unless TAPIR_LIVE_WAV and TAPIR_LIVE_GATEWAY_URL are set. Run once on 2026-10-01 with 11 min of synthetic Swedish (21 MB, above the 8-10 MB ingress cap, via the NodePort): both iguana/kb-whisper (52.8 s) and berget/kb-whisper (35.4 s) accepted the streamed, computed-Content-Length body and returned usable verbose_json. Synthetic audio only; this repo is public. Co-Authored-By: Claude Sonnet 5.5 --- internal/adapters/transcribe/live_test.go | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 internal/adapters/transcribe/live_test.go diff --git a/internal/adapters/transcribe/live_test.go b/internal/adapters/transcribe/live_test.go new file mode 100644 index 0000000..fc48bab --- /dev/null +++ b/internal/adapters/transcribe/live_test.go @@ -0,0 +1,49 @@ +package transcribe_test + +import ( + "context" + "net/http" + "os" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "git.d-ma.be/mathias/tapir/internal/adapters/transcribe" +) + +// TestGateway_LiveGateway is an opt-in check against the REAL gateway, because +// the httptest fake above can only prove what we think the gateway accepts. It +// is skipped unless TAPIR_LIVE_WAV names a 16 kHz mono WAV and the gateway +// coordinates are set: +// +// TAPIR_LIVE_WAV=/path/a.wav TAPIR_LIVE_GATEWAY_URL=http://koala:30401/v1 \ +// TAPIR_LIVE_MODEL=iguana/kb-whisper op run --env-file ~/.op-env -- \ +// go test ./internal/adapters/transcribe -run LiveGateway -v +// +// Use SYNTHETIC audio only: this repo is public and the gateway may be a cloud +// endpoint (#33). +func TestGateway_LiveGateway(t *testing.T) { + wav := os.Getenv("TAPIR_LIVE_WAV") + url := os.Getenv("TAPIR_LIVE_GATEWAY_URL") + if wav == "" || url == "" { + t.Skip("set TAPIR_LIVE_WAV and TAPIR_LIVE_GATEWAY_URL to run against the real gateway") + } + model := os.Getenv("TAPIR_LIVE_MODEL") + if model == "" { + model = "iguana/kb-whisper" + } + key := os.Getenv("LITELLM_MASTER_KEY") + require.NotEmpty(t, key, "LITELLM_MASTER_KEY must be set (via op run)") + + ctx, cancel := context.WithTimeout(context.Background(), 25*time.Minute) + defer cancel() + got, err := transcribe.NewGateway(url, key, model, &http.Client{}).Transcribe(ctx, wav) + + require.NoError(t, err) + assert.NotEmpty(t, got.Text) + assert.NotEmpty(t, got.Segments) + assert.Equal(t, model, got.Endpoint) + t.Logf("endpoint=%s audio_s=%.1f segments=%d chars=%d", got.Endpoint, got.AudioSeconds, len(got.Segments), len(got.Text)) +}