Тесты переведены на Gomega

Этот коммит содержится в:
Softonik 2021-10-03 22:58:55 +03:00 коммит произвёл Nobody
родитель 2bc8766dd9
коммит 7f10cf1cba

Просмотреть файл

@ -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