summaryrefslogtreecommitdiff
path: root/internal/processor/processor_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-02 08:16:57 +0300
committerPaul Buetow <paul@buetow.org>2026-04-02 08:16:57 +0300
commite905d0d7435a827825017c5612b6e61d1f1f5da7 (patch)
tree26d9bef15305895c0b1703c629f042800367fb04 /internal/processor/processor_test.go
parent0349a83743f8b8c8125a35b93b2271e402352b99 (diff)
Centralize audio sidecar generation
Diffstat (limited to 'internal/processor/processor_test.go')
-rw-r--r--internal/processor/processor_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/processor/processor_test.go b/internal/processor/processor_test.go
index f658713..69250bf 100644
--- a/internal/processor/processor_test.go
+++ b/internal/processor/processor_test.go
@@ -436,6 +436,7 @@ func TestGenerateAudioBgBgUsesSharedOpenAIVoices(t *testing.T) {
metadata := string(metadataData)
for _, want := range []string{
"provider=openai",
+ "cardtype=bg-bg",
"audio_file=audio_front.mp3",
"audio_file_back=audio_back.mp3",
} {
@@ -443,6 +444,19 @@ func TestGenerateAudioBgBgUsesSharedOpenAIVoices(t *testing.T) {
t.Fatalf("metadata = %q, missing %q", metadata, want)
}
}
+
+ for i, outputFile := range fakeProvider.outputFiles {
+ attrPath := audio.AttributionPath(outputFile)
+ attributionData, err := os.ReadFile(attrPath)
+ if err != nil {
+ t.Fatalf("expected attribution file %q: %v", attrPath, err)
+ }
+ attribution := string(attributionData)
+ wantText := []string{"ябълка...", "круша..."}[i]
+ if !strings.Contains(attribution, "Processed text sent to TTS: "+wantText) {
+ t.Fatalf("bg-bg attribution missing processed text %q: %q", wantText, attribution)
+ }
+ }
}
func TestGenerateAudioProviderFactoryError(t *testing.T) {
@@ -548,11 +562,22 @@ func TestGenerateAudioUsesConfiguredGeminiVoiceAndModel(t *testing.T) {
"speed=1.00",
"format=wav",
"audio_file=audio.wav",
+ "cardtype=en-bg",
} {
if !strings.Contains(metadata, want) {
t.Fatalf("metadata = %q, missing %q", metadata, want)
}
}
+
+ attrPath := audio.AttributionPath(fakeProvider.lastOutputFile)
+ attributionData, err := os.ReadFile(attrPath)
+ if err != nil {
+ t.Fatalf("expected attribution file %q: %v", attrPath, err)
+ }
+ attribution := string(attributionData)
+ if !strings.Contains(attribution, "Processed text sent to TTS: ябълка...") {
+ t.Fatalf("gemini attribution missing processed text: %q", attribution)
+ }
}
func TestGenerateAudioUsesConfiguredAudioFormatWhenOpenAIConfigIsSetOnly(t *testing.T) {
@@ -612,11 +637,22 @@ func TestGenerateAudioUsesConfiguredAudioFormatWhenOpenAIConfigIsSetOnly(t *test
"model=gpt-4o-mini-tts",
"voice=alloy",
"format=mp3",
+ "cardtype=en-bg",
} {
if !strings.Contains(metadata, want) {
t.Fatalf("metadata = %q, missing %q", metadata, want)
}
}
+
+ attrPath := audio.AttributionPath(fakeProvider.lastOutputFile)
+ attributionData, err := os.ReadFile(attrPath)
+ if err != nil {
+ t.Fatalf("expected attribution file %q: %v", attrPath, err)
+ }
+ attribution := string(attributionData)
+ if !strings.Contains(attribution, "Processed text sent to TTS: ябълка...") {
+ t.Fatalf("openai attribution missing processed text: %q", attribution)
+ }
}
func TestGenerateAnkiFileUsesEffectiveAudioFormatForGemini(t *testing.T) {