standardize processor instance creation in tests

This commit is contained in:
Joel Wetzell
2026-02-09 22:09:48 -06:00
parent f028634401
commit a408e281a3
14 changed files with 599 additions and 191 deletions

View File

@@ -49,22 +49,36 @@ func TestStringSplitFromRegistry(t *testing.T) {
func TestGoodStringSplit(t *testing.T) {
tests := []struct {
processor processor.Processor
name string
payload any
expected []string
name string
params map[string]any
payload any
expected []string
}{
{
processor: &processor.StringSplit{Separator: ","},
name: "comma separated",
payload: "part1,part2,part3",
expected: []string{"part1", "part2", "part3"},
name: "comma separated",
params: map[string]any{"separator": ","},
payload: "part1,part2,part3",
expected: []string{"part1", "part2", "part3"},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got, err := test.processor.Process(t.Context(), test.payload)
registration, ok := processor.ProcessorRegistry["string.split"]
if !ok {
t.Fatalf("string.split processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "string.split",
Params: test.params,
})
if err != nil {
t.Fatalf("string.split failed to create processor: %s", err)
}
got, err := processorInstance.Process(t.Context(), test.payload)
gotStrings, ok := got.([]string)
if !ok {