From 754e0a557d1b874668b476ef028ab5488f3bbabc Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Mon, 6 Jan 2020 16:51:02 +0800 Subject: [PATCH] todo: add wtf runtime for windows --- README.md | 1 + cmd/helper_test.go | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0eb41f7..6d8e291 100644 --- a/README.md +++ b/README.md @@ -531,6 +531,7 @@ Documents Todo: Tech Debt + - Test for Windows - Duplicate Code - cmd/ -> user builder to refactoring diff --git a/cmd/helper_test.go b/cmd/helper_test.go index e8d31f4..4200558 100644 --- a/cmd/helper_test.go +++ b/cmd/helper_test.go @@ -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 -- GitLab