fuse: Fix test for timestamps with same second

This commit is contained in:
Alexander Neumann 2016-09-18 18:13:39 +02:00
parent 7b3e319398
commit 649f789190
1 changed files with 22 additions and 3 deletions

View File

@ -4,6 +4,7 @@
package main package main
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -116,10 +117,28 @@ func TestMount(t *testing.T) {
for _, id := range snapshotIDs { for _, id := range snapshotIDs {
snapshot, err := restic.LoadSnapshot(repo, id) snapshot, err := restic.LoadSnapshot(repo, id)
OK(t, err) 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)) ts := snapshot.Time.Format(time.RFC3339)
namesMap[snapshot.Time.Format(time.RFC3339)] = true 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 { for name, present := range namesMap {
Assert(t, present, "Directory %s is present in fuse dir but is not a snapshot", name) Assert(t, present, "Directory %s is present in fuse dir but is not a snapshot", name)
} }