From 3a4922b5d747d54c9cb62833c9d69acb96b072f6 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 7 Feb 2016 10:55:13 +0100 Subject: Add tests for long name creation and renaming (currently failing, obviously) --- integration_tests/helpers.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'integration_tests/helpers.go') diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go index e5458c9..4adce97 100644 --- a/integration_tests/helpers.go +++ b/integration_tests/helpers.go @@ -1,6 +1,7 @@ package integration_tests import ( + "path/filepath" "crypto/md5" "encoding/hex" "fmt" @@ -176,3 +177,38 @@ func testRename(t *testing.T, plainDir string) { } syscall.Unlink(file2) } + +// verifyExistence - check in 3 ways that "path" exists: +// stat, open, readdir +func verifyExistence(path string) bool { + + // Check that file can be stated + _, err := os.Stat(path) + if err != nil { + //t.Log(err) + return false + } + + // Check that file can be opened + fd, err := os.Open(path) + if err != nil { + //t.Log(err) + return false + } + fd.Close() + + // Check that file shows up in directory listing + dir := filepath.Dir(path) + name := filepath.Base(path) + fi, err := ioutil.ReadDir(dir) + if err != nil { + //t.Log(err) + return false + } + for _, i := range(fi) { + if i.Name() == name { + return true + } + } + return false +} -- cgit v1.2.3