test cleanup

This commit is contained in:
Joel Wetzell
2026-02-08 21:38:44 -06:00
parent 4ea6c8f11f
commit 1c49548a4c
2 changed files with 8 additions and 13 deletions

View File

@@ -40,22 +40,20 @@ func TestStringDecodeFromRegistry(t *testing.T) {
func TestGoodStringDecode(t *testing.T) { func TestGoodStringDecode(t *testing.T) {
stringDecoder := processor.StringDecode{} stringDecoder := processor.StringDecode{}
tests := []struct { tests := []struct {
processor processor.Processor name string
name string payload any
payload any expected string
expected string
}{ }{
{ {
processor: &stringDecoder, name: "hello",
name: "hello", payload: []byte{0x68, 0x65, 0x6c, 0x6c, 0x6f},
payload: []byte{0x68, 0x65, 0x6c, 0x6c, 0x6f}, expected: "hello",
expected: "hello",
}, },
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
got, err := test.processor.Process(t.Context(), test.payload) got, err := stringDecoder.Process(t.Context(), test.payload)
gotString, ok := got.(string) gotString, ok := got.(string)
if !ok { if !ok {
@@ -74,7 +72,6 @@ func TestGoodStringDecode(t *testing.T) {
func TestBadStringDecode(t *testing.T) { func TestBadStringDecode(t *testing.T) {
stringDecoder := processor.StringDecode{} stringDecoder := processor.StringDecode{}
tests := []struct { tests := []struct {
processor processor.Processor
name string name string
payload any payload any
errorString string errorString string

View File

@@ -79,13 +79,11 @@ func TestGoodStringEncode(t *testing.T) {
func TestBadStringEncode(t *testing.T) { func TestBadStringEncode(t *testing.T) {
stringEncoder := processor.StringEncode{} stringEncoder := processor.StringEncode{}
tests := []struct { tests := []struct {
processor processor.Processor
name string name string
payload any payload any
errorString string errorString string
}{ }{
{ {
processor: &stringEncoder,
name: "non-string input", name: "non-string input",
payload: []byte{0x68, 0x65, 0x6c, 0x6c, 0x6f}, payload: []byte{0x68, 0x65, 0x6c, 0x6c, 0x6f},
errorString: "string.encode processor only accepts a string", errorString: "string.encode processor only accepts a string",
@@ -94,7 +92,7 @@ func TestBadStringEncode(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
got, err := test.processor.Process(t.Context(), test.payload) got, err := stringEncoder.Process(t.Context(), test.payload)
if err == nil { if err == nil {
t.Fatalf("string.encode expected to fail but got payload: %s", got) t.Fatalf("string.encode expected to fail but got payload: %s", got)