diff --git a/kyaml/filesys/fsondisk_test.go b/kyaml/filesys/fsondisk_test.go index d349c5063..54eff42dd 100644 --- a/kyaml/filesys/fsondisk_test.go +++ b/kyaml/filesys/fsondisk_test.go @@ -58,7 +58,8 @@ func TestCleanedAbs_2(t *testing.T) { req := require.New(t) fSys, _ := makeTestDir(t) - root := getOSRoot(t) + root, err := getOSRoot() + req.NoError(err) d, f, err := fSys.CleanedAbs(root) req.NoError(err) req.Equal(root, d.String()) @@ -122,7 +123,8 @@ func TestConfirmDirDisk(t *testing.T) { err = os.Symlink(filepath.Join(wd, relDir), linkDir) req.NoError(err) - root := getOSRoot(t) + root, err := getOSRoot() + req.NoError(err) tests := map[string]*struct { path string expected string diff --git a/kyaml/filesys/fsondisk_test_unix.go b/kyaml/filesys/fsondisk_unix.go similarity index 63% rename from kyaml/filesys/fsondisk_test_unix.go rename to kyaml/filesys/fsondisk_unix.go index 6331e4546..15935a462 100644 --- a/kyaml/filesys/fsondisk_test_unix.go +++ b/kyaml/filesys/fsondisk_unix.go @@ -8,10 +8,8 @@ package filesys import ( "path/filepath" - "testing" ) -func getOSRoot(t *testing.T) string { - t.Helper() - return string(filepath.Separator) +func getOSRoot() (string, error) { + return string(filepath.Separator), nil } diff --git a/kyaml/filesys/fsondisk_test_windows.go b/kyaml/filesys/fsondisk_windows.go similarity index 54% rename from kyaml/filesys/fsondisk_test_windows.go rename to kyaml/filesys/fsondisk_windows.go index d739664f3..8c8a33c4d 100644 --- a/kyaml/filesys/fsondisk_test_windows.go +++ b/kyaml/filesys/fsondisk_windows.go @@ -5,16 +5,14 @@ package filesys import ( "path/filepath" - "testing" - "github.com/stretchr/testify/require" "golang.org/x/sys/windows" ) -func getOSRoot(t *testing.T) string { - t.Helper() - +func getOSRoot() (string, error) { sysDir, err := windows.GetSystemDirectory() - require.NoError(t, err) - return filepath.VolumeName(sysDir) + `\` + if err != nil { + return "", err + } + return filepath.VolumeName(sysDir) + `\`, nil }