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

@@ -4,9 +4,46 @@ import (
"slices"
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestStringEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.encode"]
if !ok {
t.Fatalf("string.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "string.encode",
})
if err != nil {
t.Fatalf("failed to create string.encode processor: %s", err)
}
if processorInstance.Type() != "string.encode" {
t.Fatalf("string.encode processor has wrong type: %s", processorInstance.Type())
}
payload := "hello"
expected := []byte{'h', 'e', 'l', 'l', 'o'}
got, err := processorInstance.Process(t.Context(), payload)
if err != nil {
t.Fatalf("string.encode processing failed: %s", err)
}
gotBytes, ok := got.([]byte)
if !ok {
t.Fatalf("string.encode should return byte slice")
}
if !slices.Equal(gotBytes, expected) {
t.Fatalf("string.encode got %+v, expected %+v", got, expected)
}
}
func TestGoodStringEncode(t *testing.T) {
stringEncoder := processor.StringEncode{}
tests := []struct {