32 lines
929 B
Go
32 lines
929 B
Go
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")
|
|
}
|
|
}
|