Merge pull request #3228 from tphoney/windows_unit_tests
(maint) fix unit tests so they pass on windows
This commit is contained in:
commit
086c4b3f82
2 changed files with 20 additions and 3 deletions
|
@ -2,6 +2,8 @@ package jsonnet
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -82,13 +84,19 @@ func TestParseJsonnetNotTemplateFile(t *testing.T) {
|
|||
req.Repo.Config = "plugin.jsonnet"
|
||||
req.Config.Data = string(before)
|
||||
|
||||
parsedFile, err := Parse(req, nil, 0, nil, nil)
|
||||
got, err := Parse(req, nil, 0, nil, nil)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ package converter
|
|||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -234,7 +236,14 @@ func TestTemplatePluginConvertJsonnet(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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue