mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package processor_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/jwetzell/showbridge-go/internal/config"
|
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
|
"github.com/jwetzell/showbridge-go/internal/test"
|
|
)
|
|
|
|
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 &test.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 &test.TestProcessor{}, nil
|
|
},
|
|
})
|
|
}
|