engine: resources: Add file exists helper

This will allow us to test even more things!
This commit is contained in:
James Shubin
2019-10-25 09:40:10 -04:00
parent eaab1aae28
commit 6b1e038c5c

View File

@@ -715,6 +715,22 @@ func TestResources2(t *testing.T) {
return nil return nil
} }
} }
fileExists := func(p string, dir bool) func() error {
// does the file exist?
return func() error {
fi, err := os.Stat(p)
if err != nil {
return fmt.Errorf("file was supposed to be present, got: %+v", err)
}
if fi.IsDir() != dir {
if dir {
return fmt.Errorf("not a dir")
}
return fmt.Errorf("not a regular file")
}
return nil
}
}
fileAbsent := func(p string) func() error { fileAbsent := func(p string) func() error {
// does the file exist? // does the file exist?
return func() error { return func() error {