package whisperx import ( "context" "errors" "sync" "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) } requests := fake.RequestsSnapshot() if len(requests) != 1 || requests[0].SpeakerID != "alice" { t.Fatalf("requests = %#v, want one alice request", 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") } } func TestFakeClientRequestsSnapshotSupportsConcurrentCalls(t *testing.T) { fake := &FakeClient{} const callers = 16 var group sync.WaitGroup group.Add(callers) for i := 0; i < callers; i++ { go func() { defer group.Done() if _, err := fake.Transcribe(context.Background(), TranscribeRequest{}); err != nil { t.Errorf("Transcribe() error = %v", err) } }() } group.Wait() if got := len(fake.RequestsSnapshot()); got != callers { t.Fatalf("captured requests = %d, want %d", got, callers) } }