From b02ad128146c818e871aedc0a7b2e6655b7790e9 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 11 Dec 2015 23:27:38 +0100 Subject: tests: overwrite directory with another directory Testcase for issue #10 (currently failing) --- integration_tests/helpers.go | 1 + integration_tests/main_test.go | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'integration_tests') 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) + } +} -- cgit v1.2.3