2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

local: Add test for open non-existing dir

This commit is contained in:
Alexander Neumann 2017-09-11 21:34:00 +02:00
parent 951a34dcbf
commit 227b01395f

View File

@ -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)
}