From 8b7777d3c651681bd28dbaae3ed1a72a309ddc2c Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 22 Sep 2021 11:06:45 +0200 Subject: [PATCH] test(windows): skip failing tests on windows Signed-off-by: Mark Sagi-Kazar --- fs_test.go | 2 ++ util_test.go | 2 ++ viper_test.go | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/fs_test.go b/fs_test.go index d811f45..73abd43 100644 --- a/fs_test.go +++ b/fs_test.go @@ -13,6 +13,8 @@ import ( ) func TestFinder(t *testing.T) { + skipWindows(t) + t.Parallel() fsys := fstest.MapFS{ diff --git a/util_test.go b/util_test.go index 941d8a2..b294b49 100644 --- a/util_test.go +++ b/util_test.go @@ -58,6 +58,8 @@ func TestCopyAndInsensitiviseMap(t *testing.T) { } func TestAbsPathify(t *testing.T) { + skipWindows(t) + home := userHomeDir() homer := filepath.Join(home, "homer") wd, _ := os.Getwd() diff --git a/viper_test.go b/viper_test.go index 349d09e..abe41fe 100644 --- a/viper_test.go +++ b/viper_test.go @@ -302,6 +302,8 @@ func (s *stringValue) String() string { } func TestGetConfigFile(t *testing.T) { + skipWindows(t) + t.Run("config file set", func(t *testing.T) { fs := afero.NewMemMapFs() @@ -438,6 +440,8 @@ func TestGetConfigFile(t *testing.T) { } func TestReadInConfig(t *testing.T) { + skipWindows(t) + t.Run("config file set", func(t *testing.T) { fs := afero.NewMemMapFs() @@ -1808,6 +1812,8 @@ func TestWriteConfigDotEnv(t *testing.T) { } func TestSafeWriteConfig(t *testing.T) { + skipWindows(t) + v := New() fs := afero.NewMemMapFs() v.SetFs(fs) @@ -1831,6 +1837,8 @@ func TestSafeWriteConfigWithMissingConfigPath(t *testing.T) { } func TestSafeWriteConfigWithExistingFile(t *testing.T) { + skipWindows(t) + v := New() fs := afero.NewMemMapFs() fs.Create("/test/c.yaml") @@ -1870,6 +1878,8 @@ func TestSafeWriteConfigAsWithExistingFile(t *testing.T) { } func TestWriteHiddenFile(t *testing.T) { + skipWindows(t) + v := New() fs := afero.NewMemMapFs() fs.Create("/test/.config") @@ -2556,3 +2566,10 @@ func BenchmarkGetBoolFromMap(b *testing.B) { } } } + +// Skip some tests on Windows that kept failing when Windows was added to the CI as a target. +func skipWindows(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Skip test on Windows") + } +}