mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 09:24:23 +00:00
Replace os.Stat with IsDir, simplifying FS abstraction.
This commit is contained in:
@@ -21,34 +21,25 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStatNotExist(t *testing.T) {
|
||||
func TestExists(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
info, err := x.Stat("foo")
|
||||
if info != nil {
|
||||
t.Fatalf("expected nil info")
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatalf("expected error")
|
||||
if x.Exists("foo") {
|
||||
t.Fatalf("expected no foo")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStat(t *testing.T) {
|
||||
func TestIsDir(t *testing.T) {
|
||||
x := MakeFakeFS()
|
||||
expectedName := "my-dir"
|
||||
err := x.Mkdir(expectedName, 0666)
|
||||
err := x.Mkdir(expectedName)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
info, err := x.Stat(expectedName)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
if !x.Exists(expectedName) {
|
||||
t.Fatalf(expectedName + " should exist")
|
||||
}
|
||||
name := info.Name()
|
||||
if name != expectedName {
|
||||
t.Fatalf("expected %v but got %v", expectedName, name)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
t.Fatalf("expected IsDir() return true")
|
||||
if !x.IsDir(expectedName) {
|
||||
t.Fatalf(expectedName + " should be a dir")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +52,8 @@ func TestCreate(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error")
|
||||
}
|
||||
info, err := x.Stat("foo")
|
||||
if info == nil {
|
||||
t.Fatalf("expected non-nil info")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error")
|
||||
if !x.Exists("foo") {
|
||||
t.Fatalf("expected foo to exist")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user