2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

backend tests: Delay listing for swift backend

This commit is contained in:
Alexander Neumann 2017-06-15 19:41:07 +02:00
parent 98ae7b1210
commit eb7fc12e01

View File

@ -453,6 +453,21 @@ func delayedRemove(b restic.Backend, h restic.Handle) error {
return err
}
func delayedList(t testing.TB, b restic.Backend, tpe restic.FileType, max int) restic.IDs {
list := restic.NewIDSet()
for i := 0; i < max; i++ {
for s := range b.List(context.TODO(), tpe) {
id := restic.TestParseID(s)
list.Insert(id)
}
if len(list) < max {
time.Sleep(100 * time.Millisecond)
}
}
return list.List()
}
// TestBackend tests all functions of the backend.
func (s *Suite) TestBackend(t *testing.T) {
b := s.open(t)
@ -548,12 +563,7 @@ func (s *Suite) TestBackend(t *testing.T) {
IDs = append(IDs, id)
}
list := restic.IDs{}
for s := range b.List(context.TODO(), tpe) {
list = append(list, restic.TestParseID(s))
}
list := delayedList(t, b, tpe, len(IDs))
if len(IDs) != len(list) {
t.Fatalf("wrong number of IDs returned: want %d, got %d", len(IDs), len(list))
}