From 649f7891903c58539b031b415e91506b851f43ca Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 18 Sep 2016 18:13:39 +0200 Subject: [PATCH] fuse: Fix test for timestamps with same second --- src/cmds/restic/integration_fuse_test.go | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/cmds/restic/integration_fuse_test.go b/src/cmds/restic/integration_fuse_test.go index bfaeaf0a3..2f7a5fa9f 100644 --- a/src/cmds/restic/integration_fuse_test.go +++ b/src/cmds/restic/integration_fuse_test.go @@ -4,6 +4,7 @@ package main import ( + "fmt" "io/ioutil" "os" "path/filepath" @@ -116,10 +117,28 @@ func TestMount(t *testing.T) { for _, id := range snapshotIDs { snapshot, err := restic.LoadSnapshot(repo, id) OK(t, err) - _, ok := namesMap[snapshot.Time.Format(time.RFC3339)] - Assert(t, ok, "Snapshot %s isn't present in fuse dir", snapshot.Time.Format(time.RFC3339)) - namesMap[snapshot.Time.Format(time.RFC3339)] = true + + ts := snapshot.Time.Format(time.RFC3339) + present, ok := namesMap[ts] + if !ok { + t.Errorf("Snapshot %v (%q) isn't present in fuse dir", id.Str(), ts) + } + + for i := 1; present; i++ { + ts = fmt.Sprintf("%s-%d", snapshot.Time.Format(time.RFC3339), i) + present, ok = namesMap[ts] + if !ok { + t.Errorf("Snapshot %v (%q) isn't present in fuse dir", id.Str(), ts) + } + + if !present { + break + } + } + + namesMap[ts] = true } + for name, present := range namesMap { Assert(t, present, "Directory %s is present in fuse dir but is not a snapshot", name) }