diff --git a/transpile/service_test.go b/transpile/service_test.go index e66e77b..0c48a80 100644 --- a/transpile/service_test.go +++ b/transpile/service_test.go @@ -2,9 +2,10 @@ package transpile import ( "bytes" - "reflect" "strings" "testing" + + . "github.com/onsi/gomega" ) // Trim removes all the whitespaces and returns a new string. @@ -19,18 +20,16 @@ func Trim(s string) string { // Validate the content of a given source with an expected outcome by using a string compare. // The defaultService will be started and used to transform the source into an Arduino sketch format. func Validate(source, expected string, t *testing.T) { + RegisterTestingT(t) + var in, out bytes.Buffer in.WriteString(source) service := NewService(&in, &out) err := service.Start() got := out.String() tgot, texpected := Trim(got), Trim(expected) - if !reflect.DeepEqual(err, nil) { - t.Fatalf("got %v, but expected %v", err, nil) - } - if !reflect.DeepEqual(err, nil) { - t.Fatalf("got %v, but expected %v", tgot, texpected) - } + ExpectWithOffset(1, err).NotTo(HaveOccurred()) + ExpectWithOffset(1, tgot).To(Be(texpected)) } func Test_Empty_Package(t *testing.T) { @@ -480,3 +479,5 @@ func Test_WiFiWebClient(t *testing.T) { }` Validate(source, expected, t) } + +var Be = Equal