41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package analyzer
|
|
|
|
import "context"
|
|
|
|
// NoopRunner is a deterministic no-op analyzer adapter.
|
|
type NoopRunner struct{}
|
|
|
|
// Run returns the requested output path with placeholder metadata.
|
|
func (n *NoopRunner) Run(ctx context.Context, req AnalyzeRequest) (AnalyzeResult, error) {
|
|
if err := ctx.Err(); err != nil {
|
|
return AnalyzeResult{}, err
|
|
}
|
|
return AnalyzeResult{ArtifactPath: req.OutputPath, Metadata: map[string]any{"placeholder": true}}, nil
|
|
}
|
|
|
|
// FakeRunner captures analyze requests and returns deterministic responses.
|
|
type FakeRunner struct {
|
|
Requests []AnalyzeRequest
|
|
Err error
|
|
Result AnalyzeResult
|
|
}
|
|
|
|
// Run records request and returns configured response.
|
|
func (f *FakeRunner) Run(ctx context.Context, req AnalyzeRequest) (AnalyzeResult, error) {
|
|
if err := ctx.Err(); err != nil {
|
|
return AnalyzeResult{}, err
|
|
}
|
|
f.Requests = append(f.Requests, req)
|
|
if f.Err != nil {
|
|
return AnalyzeResult{}, f.Err
|
|
}
|
|
res := f.Result
|
|
if res.ArtifactPath == "" {
|
|
res.ArtifactPath = req.OutputPath
|
|
}
|
|
if res.Metadata == nil {
|
|
res.Metadata = map[string]any{"fake": true}
|
|
}
|
|
return res, nil
|
|
}
|