Skip to content

Commit 0eb642e

Browse files
committed
fixed TestConcurrency
1 parent 2516d10 commit 0eb642e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

client_test.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,26 @@ func TestConcurrency(t *testing.T) {
245245
return
246246
}
247247

248-
wait := make(chan struct{})
248+
const iterations = 10
249+
errors := make(chan error)
249250

250251
go func() {
251-
for i := 0; i <= 10; i++ {
252-
_, err = c.Server.GroupList()
253-
assert.NoError(t, err)
252+
defer close(errors)
253+
254+
for i := 0; i <= iterations; i++ {
255+
if _, err := c.Server.GroupList(); err != nil {
256+
errors <- err
257+
}
254258
}
255-
wait <- struct{}{}
256259
}()
257260

258-
for i := 0; i <= 10; i++ {
261+
for i := 0; i <= iterations; i++ {
259262
_, err = c.Server.GroupList()
260263
assert.NoError(t, err)
261264
}
262265

263-
// wait for go routine to finish
264-
<-wait
266+
// receive errors from go-routine and wait for completion
267+
for err := range errors {
268+
assert.NoError(t, err)
269+
}
265270
}

0 commit comments

Comments
 (0)