Skip to content

Commit

Permalink
Address feedback x2
Browse files Browse the repository at this point in the history
  • Loading branch information
annasong20 committed Jun 29, 2022
1 parent 8478251 commit 5ea0503
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
12 changes: 7 additions & 5 deletions kyaml/filesys/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
memoryAbs = "MakeFsInMemory"
memoryEmpty = "MakeEmptyDirInMemory"

existMsg = "Expected '%s' to exist \n"
existMsg = "expected '%s' to exist"
)

var filesysBuilders = map[string]func() FileSystem{
Expand Down Expand Up @@ -63,9 +63,11 @@ func setupFileSys(t *testing.T, name string) (FileSystem, string, string) {
return fSys, testDir, cleanWd(t)
case memoryAbs:
return filesysBuilders[name](), Separator, Separator
default:
require.Equal(t, memoryEmpty, name)
case memoryEmpty:
return filesysBuilders[name](), "", ""
default:
t.Fatalf("unexpected FileSystem implementation '%s'", name)
panic("unreachable point of execution")
}
}

Expand All @@ -83,7 +85,7 @@ func TestConfirmDir(t *testing.T) {

tests := map[string]*struct {
dir string
cleanDir string
expected string
}{
"Simple": {
d1Path,
Expand All @@ -103,7 +105,7 @@ func TestConfirmDir(t *testing.T) {
t.Run(subName, func(t *testing.T) {
cleanDir, err := ConfirmDir(fSys, test.dir)
require.NoError(t, err)
require.Equal(t, test.cleanDir, cleanDir.String())
require.Equal(t, test.expected, cleanDir.String())
})
}
})
Expand Down
12 changes: 6 additions & 6 deletions kyaml/filesys/fsondisk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
)

const dirMsg = "Expected '%s' to be a dir \n"
const dirMsg = "expected '%s' to be a dir"

func makeTestDir(t *testing.T) (FileSystem, string) {
t.Helper()
Expand Down Expand Up @@ -111,21 +111,21 @@ func TestConfirmDirDisk(t *testing.T) {

relDir := "actual_foo_431432"
err := fSys.Mkdir(relDir)
req.NoError(err)
req.Truef(fSys.Exists(relDir), existMsg, relDir)
t.Cleanup(func() {
err := fSys.RemoveAll(relDir)
req.NoError(err)
})
req.NoError(err)
req.Truef(fSys.Exists(relDir), existMsg, relDir)

linkDir := filepath.Join(testDir, "pointer")
err = os.Symlink(filepath.Join(wd, relDir), linkDir)
req.NoError(err)

root := getOSRoot(t)
tests := map[string]*struct {
path string
cleanPath string
path string
expected string
}{
"root": {
root,
Expand All @@ -146,7 +146,7 @@ func TestConfirmDirDisk(t *testing.T) {
t.Run(name, func(t *testing.T) {
actualPath, err := ConfirmDir(fSys, test.path)
require.NoError(t, err)
require.Equal(t, test.cleanPath, actualPath.String())
require.Equal(t, test.expected, actualPath.String())
})
}
}
Expand Down
7 changes: 5 additions & 2 deletions kyaml/filesys/fsondisk_test_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

package filesys

import "testing"
import (
"path/filepath"
"testing"
)

func getOSRoot(t *testing.T) string {
t.Helper()
return "/"
return string(filepath.Separator)
}

0 comments on commit 5ea0503

Please sign in to comment.