mirror of
https://github.com/octoleo/restic.git
synced 2024-12-27 04:32:40 +00:00
backend: Improve test for pagination in list
This commit is contained in:
parent
dd49e2b12d
commit
649c536250
@ -11,6 +11,7 @@ import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -250,7 +251,21 @@ func (s *Suite) TestList(t *testing.T) {
|
||||
const numTestFiles = 1233
|
||||
list1 := restic.NewIDSet()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
input := make(chan int, numTestFiles)
|
||||
for i := 0; i < numTestFiles; i++ {
|
||||
input <- i
|
||||
}
|
||||
close(input)
|
||||
|
||||
output := make(chan restic.ID, numTestFiles)
|
||||
|
||||
for worker := 0; worker < 5; worker++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
for i := range input {
|
||||
data := []byte(fmt.Sprintf("random test blob %v", i))
|
||||
id := restic.Hash(data)
|
||||
h := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
@ -258,6 +273,15 @@ func (s *Suite) TestList(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
output <- id
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(output)
|
||||
|
||||
for id := range output {
|
||||
list1.Insert(id)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user