Replace os.Stat with IsDir, simplifying FS abstraction.

This commit is contained in:
Jeffrey Regan
2018-07-18 11:33:30 -07:00
parent 8fda0f87ab
commit 9432671887
15 changed files with 83 additions and 69 deletions

View File

@@ -26,17 +26,30 @@ import (
func TestReadFilesRealFS(t *testing.T) {
x := MakeRealFS()
testDir := "kustomize_testing_dir"
err := x.Mkdir(testDir, 0777)
err := x.Mkdir(testDir)
defer os.RemoveAll(testDir)
if err != nil {
t.Fatalf("unexpected error %s", err)
}
if !x.Exists(testDir) {
t.Fatalf("expected existence")
}
if !x.IsDir(testDir) {
t.Fatalf("expected directory")
}
err = x.WriteFile(path.Join(testDir, "foo"), []byte(`foo`))
if err != nil {
t.Fatalf("unexpected error %s", err)
}
if !x.Exists(path.Join(testDir, "foo")) {
t.Fatalf("expected foo")
}
if x.IsDir(path.Join(testDir, "foo")) {
t.Fatalf("expected foo not to be a directory")
}
err = x.WriteFile(path.Join(testDir, "bar"), []byte(`bar`))
if err != nil {
t.Fatalf("unexpected error %s", err)