Skip to content

Commit

Permalink
rewrite getOSRoot fsondisk test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
natasha41575 committed Aug 1, 2022
1 parent db89ec5 commit 095d529
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 39 deletions.
17 changes: 15 additions & 2 deletions kyaml/filesys/fsondisk_test.go
Expand Up @@ -7,10 +7,12 @@ import (
"os"
"path/filepath"
"reflect"
"runtime"
"sort"
"testing"

"github.com/stretchr/testify/require"
"golang.org/x/sys/windows"
)

const dirMsg = "expected '%s' to be a dir"
Expand Down Expand Up @@ -58,7 +60,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())
Expand Down Expand Up @@ -122,7 +125,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
Expand Down Expand Up @@ -257,3 +261,12 @@ func TestReadFilesRealFS(t *testing.T) {
})
}
}

func getOSRoot() (string, error) {
if runtime.GOOS == "windows" {
sysDir, err := windows.GetSystemDirectory()
return filepath.VolumeName(sysDir) + `\`, err
} else {
return string(filepath.Separator), nil
}
}
17 changes: 0 additions & 17 deletions kyaml/filesys/fsondisk_unix_test.go

This file was deleted.

20 changes: 0 additions & 20 deletions kyaml/filesys/fsondisk_windows_test.go

This file was deleted.

0 comments on commit 095d529

Please sign in to comment.