...
1 package kpoll
2
3 import (
4 "fmt"
5 "strings"
6
7 "gotest.tools/v3/poll"
8 )
9
10
11
12
13
14
15
16
17
18
19
20
21
22 func JoinResults(results ...poll.Result) poll.Result {
23 if len(results) == 0 {
24 return poll.Error(fmt.Errorf("can't join 0 results, need at least one"))
25 }
26 if len(results) == 1 {
27 return results[0]
28 }
29
30 var msgs []string
31 for _, r := range results {
32 if r.Error() != nil {
33 return r
34 }
35 if !r.Done() {
36 msgs = append(msgs, r.Message())
37 }
38 }
39
40 if len(msgs) > 0 {
41 return poll.Continue("waiting on %d checks (%d/%d complete):\n%s",
42 len(msgs), len(results)-len(msgs), len(results), strings.Join(msgs, "\n\n"))
43 }
44 return poll.Success()
45 }
46
View as plain text