tests: overwrite directory with another directory

Testcase for issue #10 (currently failing)
This commit is contained in:
Jakob Unterwurzacher 2015-12-11 23:27:38 +01:00
parent 7758bdc61d
commit b02ad12814
2 changed files with 33 additions and 1 deletions

View File

@ -20,6 +20,7 @@ const defaultCipherDir = tmpDir + "cipher/"
const gocryptfsBinary = "../gocryptfs"
// resetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv
func resetTmpDir() {
fu := exec.Command("fusermount", "-z", "-u", defaultPlainDir)
fu.Run()

View File

@ -26,11 +26,15 @@ func TestMain(m *testing.M) {
if testing.Verbose() {
fmt.Printf("***** Testing with OpenSSL\n")
}
resetTmpDir()
resetTmpDir() // <- this also create gocryptfs.diriv
mount(defaultCipherDir, defaultPlainDir, "--zerokey")
r := m.Run()
unmount(defaultPlainDir)
if r != 0 {
os.Exit(r)
}
if defaultonly {
os.Exit(r)
}
@ -43,6 +47,10 @@ func TestMain(m *testing.M) {
r = m.Run()
unmount(defaultPlainDir)
if r != 0 {
os.Exit(r)
}
if testing.Verbose() {
fmt.Printf("***** Testing \"--plaintextnames\"\n")
}
@ -52,6 +60,10 @@ func TestMain(m *testing.M) {
r = m.Run()
unmount(defaultPlainDir)
if r != 0 {
os.Exit(r)
}
os.Exit(r)
}
@ -320,3 +332,22 @@ func TestMkdirRmdir(t *testing.T) {
func TestRename(t *testing.T) {
testRename(t, defaultPlainDir)
}
// Overwrite an empty directory with another directory
func TestDirOverwrite(t *testing.T) {
dir1 := defaultPlainDir + "DirOverwrite1"
dir2 := defaultPlainDir + "DirOverwrite2"
err := os.Mkdir(dir1, 0777)
if err != nil {
t.Fatal(err)
}
err = os.Mkdir(dir2, 0777)
if err != nil {
t.Fatal(err)
}
err = os.Rename(dir1, dir2)
if err != nil {
t.Fatal(err)
}
}