From 389912fa6aa6c756b226b76a1805c77243521e63 Mon Sep 17 00:00:00 2001 From: Glyn Normington Date: Mon, 17 Dec 2018 18:03:20 +0000 Subject: [PATCH] Make unit tests pass on Windows (#179) * Bump riff dependency to latest * Adjust indirect dependencies and k8s.io/apimachinery to match the changes in riff's Gopkg.lock. * Move k8s.io/apimachinery dependency from indirect to direct group in go.mod. * Redo go.sum based on Go 1.11.4 after `go clean -modcache`. See: - https://github.com/golang/go/issues/29278 - https://github.com/golang/go/issues/29282 * Add go.sum entries for Windows * Make unit tests pass and image relocate work on Windows Fixes https://github.com/pivotal-cf/pfs/issues/175 Fixes https://github.com/pivotal-cf/pfs/issues/135 --- list.go | 8 ++++++++ list_test.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/list.go b/list.go index 8803294..61b796b 100644 --- a/list.go +++ b/list.go @@ -2,6 +2,7 @@ package scan import ( "fmt" + "runtime" "strings" "github.com/ghodss/yaml" @@ -18,6 +19,13 @@ func ListImages(res string, baseDir string) ([]string, error) { imgs := []string{} docs := strings.Split(string(contents), "---\n") + if runtime.GOOS == "windows" { + // allow lines to end in LF or CRLF since either may occur + d := strings.Split(string(contents), "---\r\n") + if len(d) > len(docs) { + docs = d + } + } for _, doc := range docs { if strings.TrimSpace(doc) != "" { y := make(map[string]interface{}) diff --git a/list_test.go b/list_test.go index 6dd0f72..2b5e260 100644 --- a/list_test.go +++ b/list_test.go @@ -116,7 +116,7 @@ var _ = Describe("ListImages", func() { }) It("should return a suitable error", func() { - Expect(err).To(MatchError(HaveSuffix("no such file or directory"))) + Expect(os.IsNotExist(err)).To(BeTrue()) }) })