Define adapter interfaces and fake implementations
This commit is contained in:
40
internal/adapters/audita/fake.go
Normal file
40
internal/adapters/audita/fake.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package audita
|
||||
|
||||
import "context"
|
||||
|
||||
// NoopRunner is a deterministic no-op audita adapter.
|
||||
type NoopRunner struct{}
|
||||
|
||||
// Run returns requested output path with placeholder metadata.
|
||||
func (n *NoopRunner) Run(ctx context.Context, req PolishRequest) (PolishResult, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return PolishResult{}, err
|
||||
}
|
||||
return PolishResult{ProcessedTranscriptPath: req.OutputProcessedPath, Metadata: map[string]any{"placeholder": true}}, nil
|
||||
}
|
||||
|
||||
// FakeRunner captures polish requests and returns deterministic responses.
|
||||
type FakeRunner struct {
|
||||
Requests []PolishRequest
|
||||
Err error
|
||||
Result PolishResult
|
||||
}
|
||||
|
||||
// Run records request and returns configured response.
|
||||
func (f *FakeRunner) Run(ctx context.Context, req PolishRequest) (PolishResult, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return PolishResult{}, err
|
||||
}
|
||||
f.Requests = append(f.Requests, req)
|
||||
if f.Err != nil {
|
||||
return PolishResult{}, f.Err
|
||||
}
|
||||
res := f.Result
|
||||
if res.ProcessedTranscriptPath == "" {
|
||||
res.ProcessedTranscriptPath = req.OutputProcessedPath
|
||||
}
|
||||
if res.Metadata == nil {
|
||||
res.Metadata = map[string]any{"fake": true}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
Reference in New Issue
Block a user