Skip to content

Commit

Permalink
fixed TestConcurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
irgendwr committed Feb 10, 2019
1 parent 2516d10 commit 38b4a93
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,26 @@ func TestConcurrency(t *testing.T) {
return
}

wait := make(chan struct{})
const iterations = 10
errors := make(chan error)

go func() {
for i := 0; i <= 10; i++ {
_, err = c.Server.GroupList()
assert.NoError(t, err)
defer close(errors)

for i := 0; i <= iterations; i++ {
if _, err = c.Server.GroupList(); err != nil {
errors <- err
}
}
wait <- struct{}{}
}()

for i := 0; i <= 10; i++ {
for i := 0; i <= iterations; i++ {
_, err = c.Server.GroupList()
assert.NoError(t, err)
}

// wait for go routine to finish
<-wait
// receive errors from go-routine and wait for completion
for err := range errors {
assert.NoError(t, err)
}
}

0 comments on commit 38b4a93

Please sign in to comment.