aboutsummaryrefslogtreecommitdiff
path: root/integration_tests/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'integration_tests/helpers.go')
-rw-r--r--integration_tests/helpers.go36
1 files changed, 36 insertions, 0 deletions
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
+}