forked from TrueCloudLab/restic
local: Add test for open non-existing dir
This commit is contained in:
parent
951a34dcbf
commit
227b01395f
1 changed files with 19 additions and 0 deletions
|
@ -104,6 +104,20 @@ func openclose(t testing.TB, dir string) {
|
|||
}
|
||||
}
|
||||
|
||||
func mkdir(t testing.TB, dir string) {
|
||||
err := os.Mkdir(dir, 0700)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func removeAll(t testing.TB, dir string) {
|
||||
err := os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenNotExistingDirectory(t *testing.T) {
|
||||
dir, cleanup := TempDir(t)
|
||||
defer cleanup()
|
||||
|
@ -114,4 +128,9 @@ func TestOpenNotExistingDirectory(t *testing.T) {
|
|||
|
||||
openclose(t, dir)
|
||||
empty(t, dir)
|
||||
|
||||
mkdir(t, filepath.Join(dir, "data"))
|
||||
openclose(t, dir)
|
||||
removeAll(t, filepath.Join(dir, "data"))
|
||||
empty(t, dir)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue