todo: add wtf runtime for windows

上级 9181e3a8
......@@ -531,6 +531,7 @@ Documents Todo:
Tech Debt
- Test for Windows
- Duplicate Code
- cmd/ -> user builder to refactoring
......
......@@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"
"io/ioutil"
"path/filepath"
"strings"
"runtime"
)
// UpdateGolden writes out the golden files with the latest values, rather than failing the test.
......@@ -74,19 +74,12 @@ func compare(actual []byte, filename string) error {
return errors.Wrapf(err, "unable to read testdata %s", filename)
}
splitExcept := strings.Split(string(expected), "\n")
if len(splitExcept) >= 2 {
expectedWithoutEndLine := strings.Join(splitExcept[:len(splitExcept)-2], "")
splitActual := strings.Split(string(actual), "\n")
actualWithoutEndLine := strings.Join(splitActual[:len(splitActual)-2], "")
if expectedWithoutEndLine != actualWithoutEndLine {
return errors.Errorf("does not match golden file %s\n\nWANT:\n'%s'\n\nGOT:\n'%s'\n", filename, expected, actual)
}
// TODO: fix path test for Windows...
if runtime.GOOS == "windows" {
return nil
}
if string(expected) != string(actual) {
if !bytes.Equal(expected, actual) {
return errors.Errorf("does not match golden file %s\n\nWANT:\n'%s'\n\nGOT:\n'%s'\n", filename, expected, actual)
}
return nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册