From fab585ec0193ec20b46b4d095af5c7226162c89d Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 20 Jan 2019 13:41:20 +0100 Subject: tests: matrix: split out directory tests into their own file matrix_test.go is already too big. --- tests/matrix/dir_test.go | 32 ++++++++++++++++++++++++++++++++ tests/matrix/matrix_test.go | 25 +------------------------ 2 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 tests/matrix/dir_test.go diff --git a/tests/matrix/dir_test.go b/tests/matrix/dir_test.go new file mode 100644 index 0000000..e7a0b22 --- /dev/null +++ b/tests/matrix/dir_test.go @@ -0,0 +1,32 @@ +package matrix + +import ( + "os" + "syscall" + "testing" + + "github.com/rfjakob/gocryptfs/tests/test_helpers" +) + +// Test Mkdir and Rmdir +func TestMkdirRmdir(t *testing.T) { + test_helpers.TestMkdirRmdir(t, test_helpers.DefaultPlainDir) +} + +// Overwrite an empty directory with another directory +func TestDirOverwrite(t *testing.T) { + dir1 := test_helpers.DefaultPlainDir + "/DirOverwrite1" + dir2 := test_helpers.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 = syscall.Rename(dir1, dir2) + if err != nil { + t.Fatal(err) + } +} diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go index e4c6b5f..be47990 100644 --- a/tests/matrix/matrix_test.go +++ b/tests/matrix/matrix_test.go @@ -372,34 +372,11 @@ func TestFilenameEncryption(t *testing.T) { } } -// Test Mkdir and Rmdir -func testMkdirRmdir(t *testing.T) { - test_helpers.TestMkdirRmdir(t, test_helpers.DefaultPlainDir) -} - // Test Rename -func testRename(t *testing.T) { +func TestRename(t *testing.T) { test_helpers.TestRename(t, test_helpers.DefaultPlainDir) } -// Overwrite an empty directory with another directory -func TestDirOverwrite(t *testing.T) { - dir1 := test_helpers.DefaultPlainDir + "/DirOverwrite1" - dir2 := test_helpers.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 = syscall.Rename(dir1, dir2) - if err != nil { - t.Fatal(err) - } -} - func TestLongNames(t *testing.T) { fi, err := ioutil.ReadDir(test_helpers.DefaultCipherDir) if err != nil { -- cgit v1.2.3