Define adapter interfaces and fake implementations
This commit is contained in:
45
internal/adapters/whisperx/fake.go
Normal file
45
internal/adapters/whisperx/fake.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package whisperx
|
||||
|
||||
import "context"
|
||||
|
||||
// NoopClient is a deterministic no-op WhisperX adapter.
|
||||
type NoopClient struct{}
|
||||
|
||||
// Transcribe returns the requested output path with placeholder metadata.
|
||||
func (n *NoopClient) Transcribe(ctx context.Context, req TranscribeRequest) (TranscribeResult, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return TranscribeResult{}, err
|
||||
}
|
||||
return TranscribeResult{
|
||||
OutputRawTranscriptPath: req.OutputRawTranscriptPath,
|
||||
Metadata: map[string]any{
|
||||
"placeholder": true,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// FakeClient captures requests and returns deterministic responses for tests.
|
||||
type FakeClient struct {
|
||||
Requests []TranscribeRequest
|
||||
Err error
|
||||
Result TranscribeResult
|
||||
}
|
||||
|
||||
// Transcribe records the request and returns either configured error or result.
|
||||
func (f *FakeClient) Transcribe(ctx context.Context, req TranscribeRequest) (TranscribeResult, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return TranscribeResult{}, err
|
||||
}
|
||||
f.Requests = append(f.Requests, req)
|
||||
if f.Err != nil {
|
||||
return TranscribeResult{}, f.Err
|
||||
}
|
||||
res := f.Result
|
||||
if res.OutputRawTranscriptPath == "" {
|
||||
res.OutputRawTranscriptPath = req.OutputRawTranscriptPath
|
||||
}
|
||||
if res.Metadata == nil {
|
||||
res.Metadata = map[string]any{"fake": true}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
Reference in New Issue
Block a user