Define adapter interfaces and fake implementations
This commit is contained in:
31
internal/adapters/whisperx/fake_test.go
Normal file
31
internal/adapters/whisperx/fake_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package whisperx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFakeClientCapturesRequestAndReturnsPath(t *testing.T) {
|
||||
fake := &FakeClient{}
|
||||
req := TranscribeRequest{SpeakerID: "alice", AudioPath: "audio/alice.flac", OutputRawTranscriptPath: "transcripts/raw/alice.json"}
|
||||
|
||||
res, err := fake.Transcribe(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("Transcribe() error = %v", err)
|
||||
}
|
||||
if len(fake.Requests) != 1 || fake.Requests[0].SpeakerID != "alice" {
|
||||
t.Fatalf("requests = %#v, want one alice request", fake.Requests)
|
||||
}
|
||||
if res.OutputRawTranscriptPath != req.OutputRawTranscriptPath {
|
||||
t.Fatalf("output path = %q, want %q", res.OutputRawTranscriptPath, req.OutputRawTranscriptPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakeClientError(t *testing.T) {
|
||||
fake := &FakeClient{Err: errors.New("boom")}
|
||||
_, err := fake.Transcribe(context.Background(), TranscribeRequest{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user