Тесты переведены на Gomega
Этот коммит содержится в:
родитель
2bc8766dd9
коммит
7f10cf1cba
1 изменённых файлов: 8 добавлений и 7 удалений
|
@ -2,9 +2,10 @@ package transpile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Trim removes all the whitespaces and returns a new string.
|
// 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.
|
// 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.
|
// The defaultService will be started and used to transform the source into an Arduino sketch format.
|
||||||
func Validate(source, expected string, t *testing.T) {
|
func Validate(source, expected string, t *testing.T) {
|
||||||
|
RegisterTestingT(t)
|
||||||
|
|
||||||
var in, out bytes.Buffer
|
var in, out bytes.Buffer
|
||||||
in.WriteString(source)
|
in.WriteString(source)
|
||||||
service := NewService(&in, &out)
|
service := NewService(&in, &out)
|
||||||
err := service.Start()
|
err := service.Start()
|
||||||
got := out.String()
|
got := out.String()
|
||||||
tgot, texpected := Trim(got), Trim(expected)
|
tgot, texpected := Trim(got), Trim(expected)
|
||||||
if !reflect.DeepEqual(err, nil) {
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
t.Fatalf("got %v, but expected %v", err, nil)
|
ExpectWithOffset(1, tgot).To(Be(texpected))
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(err, nil) {
|
|
||||||
t.Fatalf("got %v, but expected %v", tgot, texpected)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Empty_Package(t *testing.T) {
|
func Test_Empty_Package(t *testing.T) {
|
||||||
|
@ -480,3 +479,5 @@ func Test_WiFiWebClient(t *testing.T) {
|
||||||
}`
|
}`
|
||||||
Validate(source, expected, t)
|
Validate(source, expected, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Be = Equal
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче