Improve test coverage.

This commit is contained in:
jregan
2018-10-28 13:07:15 -07:00
parent 383b3e798b
commit 885c1952a4
6 changed files with 230 additions and 115 deletions

View File

@@ -27,6 +27,10 @@ func TestExists(t *testing.T) {
if x.Exists("foo") {
t.Fatalf("expected no foo")
}
x.Mkdir("/")
if !x.IsDir("/") {
t.Fatalf("expected dir at /")
}
}
func TestIsDir(t *testing.T) {
@@ -44,6 +48,27 @@ func TestIsDir(t *testing.T) {
}
}
func TestIsDirDeeper(t *testing.T) {
x := MakeFakeFS()
x.WriteFile("/foo/project/file.yaml", []byte("Unused"))
x.WriteFile("/foo/project/subdir/file.yaml", []byte("Unused"))
if !x.IsDir("/") {
t.Fatalf("/ should be a dir")
}
if !x.IsDir("/foo") {
t.Fatalf("/foo should be a dir")
}
if !x.IsDir("/foo/project") {
t.Fatalf("/foo/project should be a dir")
}
if x.IsDir("/fo") {
t.Fatalf("/fo should not be a dir")
}
if x.IsDir("/x") {
t.Fatalf("/x should not be a dir")
}
}
func TestCreate(t *testing.T) {
x := MakeFakeFS()
f, err := x.Create("foo")