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"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -250,14 +251,37 @@ func (s *Suite) TestList(t *testing.T) {
|
|||||||
const numTestFiles = 1233
|
const numTestFiles = 1233
|
||||||
list1 := restic.NewIDSet()
|
list1 := restic.NewIDSet()
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
input := make(chan int, numTestFiles)
|
||||||
for i := 0; i < numTestFiles; i++ {
|
for i := 0; i < numTestFiles; i++ {
|
||||||
data := []byte(fmt.Sprintf("random test blob %v", i))
|
input <- i
|
||||||
id := restic.Hash(data)
|
}
|
||||||
h := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
close(input)
|
||||||
err := b.Save(context.TODO(), h, bytes.NewReader(data))
|
|
||||||
if err != nil {
|
output := make(chan restic.ID, numTestFiles)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
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()}
|
||||||
|
err := b.Save(context.TODO(), h, bytes.NewReader(data))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
output <- id
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
close(output)
|
||||||
|
|
||||||
|
for id := range output {
|
||||||
list1.Insert(id)
|
list1.Insert(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user