mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
test error cleanup
This commit is contained in:
@@ -37,13 +37,13 @@ func TestGoodFloatParse(t *testing.T) {
|
||||
|
||||
gotFloat, ok := got.(float64)
|
||||
if !ok {
|
||||
t.Errorf("float.parse returned a %T payload: %s", got, got)
|
||||
t.Fatalf("float.parse returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("float.parse failed: %s", err)
|
||||
t.Fatalf("float.parse failed: %s", err)
|
||||
}
|
||||
if gotFloat != test.expected {
|
||||
t.Errorf("float.parse got %f, expected %f", gotFloat, test.expected)
|
||||
t.Fatalf("float.parse got %f, expected %f", gotFloat, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -74,11 +74,11 @@ func TestBadFloatParse(t *testing.T) {
|
||||
got, err := floatParser.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("float.parse expected to fail but succeeded, got: %v", got)
|
||||
t.Fatalf("float.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
}
|
||||
if err.Error() != test.errorString {
|
||||
t.Errorf("float.parse got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
t.Fatalf("float.parse got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ func TestGoodIntParse(t *testing.T) {
|
||||
|
||||
gotInt, ok := got.(int64)
|
||||
if !ok {
|
||||
t.Errorf("int.parse returned a %T payload: %s", got, got)
|
||||
t.Fatalf("int.parse returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("int.parse failed: %s", err)
|
||||
t.Fatalf("int.parse failed: %s", err)
|
||||
}
|
||||
if gotInt != test.expected {
|
||||
t.Errorf("int.parse got %d, expected %d", gotInt, test.expected)
|
||||
t.Fatalf("int.parse got %d, expected %d", gotInt, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -74,11 +74,11 @@ func TestBadIntParse(t *testing.T) {
|
||||
got, err := intParser.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("int.parse expected to fail but succeeded, got: %v", got)
|
||||
t.Fatalf("int.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
}
|
||||
if err.Error() != test.errorString {
|
||||
t.Errorf("int.parse got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
t.Fatalf("int.parse got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestGoodScriptExpr(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
program, err := expr.Compile(test.program)
|
||||
if err != nil {
|
||||
t.Errorf("script.expr failed to compile program: %s", err)
|
||||
t.Fatalf("script.expr failed to compile program: %s", err)
|
||||
}
|
||||
|
||||
exprProcessor := &processor.ScriptExpr{Program: program}
|
||||
@@ -46,12 +46,12 @@ func TestGoodScriptExpr(t *testing.T) {
|
||||
got, err := exprProcessor.Process(t.Context(), test.payload)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("script.expr failed: %s", err)
|
||||
t.Fatalf("script.expr failed: %s", err)
|
||||
}
|
||||
|
||||
//TODO(jwetzell): work out better way to compare the any/any
|
||||
if got != test.expected {
|
||||
t.Errorf("script.expr got %+v (%T), expected %+v (%T)", got, got, test.expected, test.expected)
|
||||
t.Fatalf("script.expr got %+v (%T), expected %+v (%T)", got, got, test.expected, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodStringCreate(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
template, err := template.New("template").Parse(test.template)
|
||||
if err != nil {
|
||||
t.Errorf("string.create template parsing failed: %s", err)
|
||||
t.Fatalf("string.create template parsing failed: %s", err)
|
||||
}
|
||||
|
||||
processor := &processor.StringCreate{Template: template}
|
||||
@@ -68,13 +68,13 @@ func TestGoodStringCreate(t *testing.T) {
|
||||
|
||||
gotStrings, ok := got.(string)
|
||||
if !ok {
|
||||
t.Errorf("string.create returned a %T payload: %s", got, got)
|
||||
t.Fatalf("string.create returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("string.create failed: %s", err)
|
||||
t.Fatalf("string.create failed: %s", err)
|
||||
}
|
||||
if gotStrings != test.expected {
|
||||
t.Errorf("string.create got %s, expected %s", got, test.expected)
|
||||
t.Fatalf("string.create got %s, expected %s", got, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ func TestGoodStringDecode(t *testing.T) {
|
||||
|
||||
gotString, ok := got.(string)
|
||||
if !ok {
|
||||
t.Errorf("string.decode returned a %T payload: %s", got, got)
|
||||
t.Fatalf("string.decode returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("string.decode failed: %s", err)
|
||||
t.Fatalf("string.decode failed: %s", err)
|
||||
}
|
||||
if gotString != test.expected {
|
||||
t.Errorf("string.decode got %s, expected %s", got, test.expected)
|
||||
t.Fatalf("string.decode got %s, expected %s", got, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -61,10 +61,10 @@ func TestBadStringDecode(t *testing.T) {
|
||||
got, err := test.processor.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("string.decode expected to fail but got payload: %s", got)
|
||||
t.Fatalf("string.decode expected to fail but got payload: %s", got)
|
||||
}
|
||||
if err.Error() != test.errorString {
|
||||
t.Errorf("string.decode got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
t.Fatalf("string.decode got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ func TestGoodStringEncode(t *testing.T) {
|
||||
|
||||
gotBytes, ok := got.([]byte)
|
||||
if !ok {
|
||||
t.Errorf("string.encode returned a %T payload: %s", got, got)
|
||||
t.Fatalf("string.encode returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("string.encode failed: %s", err)
|
||||
t.Fatalf("string.encode failed: %s", err)
|
||||
}
|
||||
if !slices.Equal(gotBytes, test.expected) {
|
||||
t.Errorf("string.encode got %s, expected %s", got, test.expected)
|
||||
t.Fatalf("string.encode got %s, expected %s", got, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -62,10 +62,10 @@ func TestBadStringEncode(t *testing.T) {
|
||||
got, err := test.processor.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("string.encode expected to fail but got payload: %s", got)
|
||||
t.Fatalf("string.encode expected to fail but got payload: %s", got)
|
||||
}
|
||||
if err.Error() != test.errorString {
|
||||
t.Errorf("string.encode got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
t.Fatalf("string.encode got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ func TestGoodStringSplit(t *testing.T) {
|
||||
|
||||
gotStrings, ok := got.([]string)
|
||||
if !ok {
|
||||
t.Errorf("string.split returned a %T payload: %s", got, got)
|
||||
t.Fatalf("string.split returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("string.split failed: %s", err)
|
||||
t.Fatalf("string.split failed: %s", err)
|
||||
}
|
||||
if !slices.Equal(gotStrings, test.expected) {
|
||||
t.Errorf("string.split got %s, expected %s", got, test.expected)
|
||||
t.Fatalf("string.split got %s, expected %s", got, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -60,10 +60,10 @@ func TestBadStringSplit(t *testing.T) {
|
||||
got, err := test.processor.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("string.split expected error but got none, payload: %s", got)
|
||||
t.Fatalf("string.split expected error but got none, payload: %s", got)
|
||||
}
|
||||
if err.Error() != test.errorString {
|
||||
t.Errorf("string.split got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
t.Fatalf("string.split got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ func TestGoodUintParse(t *testing.T) {
|
||||
|
||||
gotUint, ok := got.(uint64)
|
||||
if !ok {
|
||||
t.Errorf("uint.parse returned a %T payload: %s", got, got)
|
||||
t.Fatalf("uint.parse returned a %T payload: %s", got, got)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("uint.parse failed: %s", err)
|
||||
t.Fatalf("uint.parse failed: %s", err)
|
||||
}
|
||||
if gotUint != test.expected {
|
||||
t.Errorf("uint.parse got %d, expected %d", gotUint, test.expected)
|
||||
t.Fatalf("uint.parse got %d, expected %d", gotUint, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -69,11 +69,11 @@ func TestBadUintParse(t *testing.T) {
|
||||
got, err := uintParser.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("uint.parse expected to fail but succeeded, got: %v", got)
|
||||
t.Fatalf("uint.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
}
|
||||
if err.Error() != test.errorString {
|
||||
t.Errorf("uint.parse got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
t.Fatalf("uint.parse got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user