Don't loop forever; close channel

This commit is contained in:
Till Faelligen 2022-09-15 07:06:37 +02:00
parent ed183b1a2a
commit 63a319bce7
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -129,7 +129,12 @@ func runTests(baseURL, branchName string) error {
go func() { go func() {
syncClient := users[0].client syncClient := users[0].client
since := "" since := ""
for { for len(wantEventIDs) > 0 {
select {
case <-doneCh:
return
default:
}
syncResp, err := syncClient.SyncRequest(1000, since, "1", false, "") syncResp, err := syncClient.SyncRequest(1000, since, "1", false, "")
if err != nil { if err != nil {
continue continue
@ -140,17 +145,16 @@ func runTests(baseURL, branchName string) error {
continue continue
} }
delete(wantEventIDs, ev.ID) delete(wantEventIDs, ev.ID)
if len(wantEventIDs) == 0 {
close(doneCh)
}
} }
} }
since = syncResp.NextBatch since = syncResp.NextBatch
} }
close(doneCh)
}() }()
select { select {
case <-time.After(time.Second * 10): case <-time.After(time.Second * 10):
close(doneCh)
return fmt.Errorf("failed to receive all expected messages: %+v", wantEventIDs) return fmt.Errorf("failed to receive all expected messages: %+v", wantEventIDs)
case <-doneCh: case <-doneCh:
} }