Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/cache/native/native_test.go
2017-05-12 22:32:24 +03:00

38 lignes
623 o
Go

package native
import (
"sync"
"testing"
"github.com/ewhal/nyaa/common"
"github.com/ewhal/nyaa/model"
)
// Basic test for deadlocks and race conditions
func TestConcurrency(t *testing.T) {
c := New(0.000001)
fn := func() ([]model.Torrent, int, error) {
return []model.Torrent{{}, {}, {}}, 10, nil
}
var wg sync.WaitGroup
wg.Add(300)
for i := 0; i < 3; i++ {
go func() {
for j := 0; j < 100; j++ {
go func(j int) {
defer wg.Done()
k := common.SearchParam{
Page: j,
}
if _, _, err := c.Get(k, fn); err != nil {
t.Fatal(err)
}
}(j)
}
}()
}
wg.Wait()
}