mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
test cleanup
This commit is contained in:
@@ -40,13 +40,11 @@ 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",
|
||||||
@@ -55,7 +53,7 @@ func TestGoodStringDecode(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 := 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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user