From 0fa056327a04e5d84ef7708ef2057acb9d05a436 Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Mon, 26 Jul 2021 16:43:57 -0700 Subject: [PATCH] Skip in-memory tests for Windows and generate temporary directories correctly for Windows tests. --- kyaml/kio/pkgio_writer_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kyaml/kio/pkgio_writer_test.go b/kyaml/kio/pkgio_writer_test.go index 4db505437..506fa8e49 100644 --- a/kyaml/kio/pkgio_writer_test.go +++ b/kyaml/kio/pkgio_writer_test.go @@ -6,7 +6,9 @@ package kio_test import ( "fmt" "math/rand" + "os" "path/filepath" + "runtime" "testing" "time" @@ -282,7 +284,10 @@ metadata: func testWriterOnDiskAndOnMem(t *testing.T, f func(t *testing.T, fs filesys.FileSystem)) { t.Run("on_disk", func(t *testing.T) { f(t, filesys.MakeFsOnDisk()) }) - t.Run("on_mem", func(t *testing.T) { f(t, filesys.MakeFsInMemory()) }) + // TODO: Once fsnode supports Windows, these tests should also be run. + if runtime.GOOS != "windows" { + t.Run("on_mem", func(t *testing.T) { f(t, filesys.MakeFsInMemory()) }) + } } func getWriterInputs(t *testing.T, mockFS filesys.FileSystem) (string, *yaml.RNode, *yaml.RNode, *yaml.RNode, func()) { @@ -312,8 +317,9 @@ metadata: `) require.NoError(t, err) + // These two lines are similar to calling ioutil.TempDir, but we don't actually create any directory. rand.Seed(time.Now().Unix()) - path := fmt.Sprintf("/tmp/kyaml-test%d", rand.Int31()) + path := filepath.Join(os.TempDir(), fmt.Sprintf("kyaml-test%d", rand.Int31())) require.NoError(t, mockFS.MkdirAll(filepath.Join(path, "a"))) return path, node1, node2, node3, func() { require.NoError(t, mockFS.RemoveAll(path)) } }