X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/d73a88b9e0835b1d7f0711e02db56555101a7830..c781f79f3c8cb9a7577ee1574d196988da2719b3:/voice_transcriber_test.go diff --git a/voice_transcriber_test.go b/voice_transcriber_test.go index 48732f7..c04d091 100644 --- a/voice_transcriber_test.go +++ b/voice_transcriber_test.go @@ -29,6 +29,7 @@ printf ' A made-up voice transcript.\n' > "$output.txt" printf 'private speech in process output' printf 'private speech in process errors' >&2 `) + data := []byte("made-up audio") text := transcriber.Text(t.Context(), store, data) require.Contains(t, text, "[voice ") @@ -57,10 +58,20 @@ func TestVoiceFailuresKeepStoredAudioAndSafeMarkers(t *testing.T) { name string script string }{ - {name: "failed process does not expose its errors", script: "echo secret-speech >&2; exit 1"}, - {name: "missing transcript gets a marker", script: "exit 0"}, - {name: "empty transcript gets a marker", script: "while [ \"$1\" != --output-file ]; do shift; done; shift; touch \"$1.txt\""}, + { + name: "failed process does not expose its errors", + script: "echo secret-speech >&2; exit 1", + }, + { + name: "missing transcript gets a marker", + script: "exit 0", + }, + { + name: "empty transcript gets a marker", + script: "while [ \"$1\" != --output-file ]; do shift; done; shift; touch \"$1.txt\"", + }, } + for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { store, transcriber := voiceTestInput(t, tc.script) @@ -144,7 +155,10 @@ func TestVoiceConfigReadsExplicitLocalPaths(t *testing.T) { config, err := loadConfig(dir) require.NoError(t, err) - require.Equal(t, VoiceConfig{Transcriber: "local-whisper", Model: "model.bin"}, config.Voice) + require.Equal(t, VoiceConfig{ + Transcriber: "local-whisper", + Model: "model.bin", + }, config.Voice) } func TestVoiceLookupHonorsExplicitThenNixThenPath(t *testing.T) { @@ -178,8 +192,11 @@ func TestVoiceLookupHonorsExplicitThenNixThenPath(t *testing.T) { available: true, }, { - name: "invalid explicit executable does not fall back", - config: VoiceConfig{Transcriber: "missing", Model: valid.Model}, + name: "invalid explicit executable does not fall back", + config: VoiceConfig{ + Transcriber: "missing", + Model: valid.Model, + }, program: valid.Transcriber, }, { @@ -193,6 +210,7 @@ func TestVoiceLookupHonorsExplicitThenNixThenPath(t *testing.T) { program: valid.Transcriber, }, } + for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { program, model, err := voiceLookup(tc.config, tc.program, tc.model)