aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-12-11 23:27:38 +0100
committerJakob Unterwurzacher2015-12-11 23:27:38 +0100
commitb02ad128146c818e871aedc0a7b2e6655b7790e9 (patch)
treebd17efa3cc914b6d1afe790bd06902155000e7f5
parent7758bdc61d10a5bb1daec3bdfb0af5d287c89657 (diff)
tests: overwrite directory with another directory
Testcase for issue #10 (currently failing)
-rw-r--r--integration_tests/helpers.go1
-rw-r--r--integration_tests/main_test.go33
2 files changed, 33 insertions, 1 deletions
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go
index 750283d..7c4aeef 100644
--- a/integration_tests/helpers.go
+++ b/integration_tests/helpers.go
@@ -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()
diff --git a/integration_tests/main_test.go b/integration_tests/main_test.go
index 398a9d4..cfa481d 100644
--- a/integration_tests/main_test.go
+++ b/integration_tests/main_test.go
@@ -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)
+ }
+}