add complete test coverage for string processors

This commit is contained in:
Joel Wetzell
2026-01-17 20:42:37 -06:00
parent 589c59c693
commit 7d91e64ec4
3 changed files with 174 additions and 0 deletions

View File

@@ -3,9 +3,40 @@ package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestStringDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.decode"]
if !ok {
t.Fatalf("string.decode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "string.decode",
})
if err != nil {
t.Fatalf("failed to create string.decode processor: %s", err)
}
if processorInstance.Type() != "string.decode" {
t.Fatalf("string.decode processor has wrong type: %s", processorInstance.Type())
}
payload := []byte{'h', 'e', 'l', 'l', 'o'}
expected := "hello"
got, err := processorInstance.Process(t.Context(), payload)
if err != nil {
t.Fatalf("string.decode processing failed: %s", err)
}
if got != expected {
t.Fatalf("string.decode got %+v, expected %+v", got, expected)
}
}
func TestGoodStringDecode(t *testing.T) {
stringDecoder := processor.StringDecode{}
tests := []struct {