From 7dcac9470a9175213a5ed4231bcb7e30082d6cd1 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Wed, 24 Dec 2025 20:15:46 -0600 Subject: [PATCH] tests for general processor stuff --- internal/processor/processor_test.go | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 internal/processor/processor_test.go diff --git a/internal/processor/processor_test.go b/internal/processor/processor_test.go new file mode 100644 index 0000000..76e8173 --- /dev/null +++ b/internal/processor/processor_test.go @@ -0,0 +1,62 @@ +package processor_test + +import ( + "context" + "testing" + + "github.com/jwetzell/showbridge-go/internal/config" + "github.com/jwetzell/showbridge-go/internal/processor" +) + +type TestProcessor struct { +} + +func (p *TestProcessor) Type() string { + return "test" +} +func (p *TestProcessor) Process(ctx context.Context, input any) (any, error) { + return input, nil +} + +func TestProcessorBadRegistrationNoType(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Fatalf("processor registration should have panicked but did not") + } + }() + + processor.RegisterProcessor(processor.ProcessorRegistration{ + Type: "", + New: func(config config.ProcessorConfig) (processor.Processor, error) { + return &TestProcessor{}, nil + }, + }) +} + +func TestProcessorBadRegistrationNoNew(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Fatalf("processor registration should have panicked but did not") + } + }() + + processor.RegisterProcessor(processor.ProcessorRegistration{ + Type: "test", + New: nil, + }) +} + +func TestProcessorBadRegistrationExistingType(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Fatalf("processor registration should have panicked but did not") + } + }() + + processor.RegisterProcessor(processor.ProcessorRegistration{ + Type: "string.create", + New: func(config config.ProcessorConfig) (processor.Processor, error) { + return &TestProcessor{}, nil + }, + }) +}