test(05-03): add failing tests for VerifyAll worker pool
- TestVerifyAll_MultipleFindings: 5 findings via 3-worker pool - TestVerifyAll_MissingProvider: unknown provider yields StatusUnknown - TestVerifyAll_ContextCancellation: cancellation closes channel early - Add providers.NewRegistryFromProviders test helper
This commit is contained in:
@@ -39,6 +39,21 @@ func NewRegistry() (*Registry, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewRegistryFromProviders builds a Registry from an explicit slice of providers
|
||||
// without touching the embedded YAML files. Intended for tests that need a
|
||||
// minimal registry with synthetic providers.
|
||||
func NewRegistryFromProviders(ps []Provider) *Registry {
|
||||
index := make(map[string]int, len(ps))
|
||||
var keywords []string
|
||||
for i, p := range ps {
|
||||
index[p.Name] = i
|
||||
keywords = append(keywords, p.Keywords...)
|
||||
}
|
||||
builder := ahocorasick.NewAhoCorasickBuilder(ahocorasick.Opts{DFA: true})
|
||||
ac := builder.Build(keywords)
|
||||
return &Registry{providers: ps, index: index, ac: ac}
|
||||
}
|
||||
|
||||
// List returns all loaded providers.
|
||||
func (r *Registry) List() []Provider {
|
||||
return r.providers
|
||||
|
||||
Reference in New Issue
Block a user