(maint) fix starlark/jsonnet tests on windows

This commit is contained in:
TP Honey 2022-06-14 11:39:28 +01:00
parent 086c4b3f82
commit 2a70ce51cc
2 changed files with 18 additions and 3 deletions

View file

@ -46,13 +46,19 @@ func TestParse(t *testing.T) {
req.Config.Data = string(before)
parsedFile, err := Parse(req, nil, 0, template, templateData)
got, err := Parse(req, nil, 0, template, templateData)
if err != nil {
t.Error(err)
return
}
if want, got := parsedFile, string(after); want != got {
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -16,6 +16,8 @@ package converter
import (
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -117,7 +119,14 @@ func TestConvert_Multi(t *testing.T) {
return
}
if want, got := config.Data, string(after); want != got {
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
t.Errorf("Want %q got %q", want, got)
}
}