Merge pull request #3230 from tphoney/starlark_windows_tests

(maint) fix starlark test on windows
This commit is contained in:
TP Honey 2022-06-14 11:56:19 +01:00 committed by GitHub
commit 39e194ab11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)
}
}