| 21 | const TestChannelTimeout = 30 * time.Second |
| 22 | |
| 23 | func WaitForChannel(t *testing.T, ch <-chan error, message string) { |
| 24 | if message != "" { |
| 25 | log.Printf("[%s] starting wait", message) |
| 26 | defer func() { |
| 27 | log.Printf("[%s] completed wait", message) |
| 28 | }() |
| 29 | } |
| 30 | select { |
| 31 | case err := <-ch: |
| 32 | if err != nil { |
| 33 | require.Fail(t, fmt.Sprintf("[%s] channel returned error: %v", message, err)) |
| 34 | } |
| 35 | return |
| 36 | case <-time.After(TestChannelTimeout): |
| 37 | require.Fail(t, fmt.Sprintf("[%s] expected channel message did not arrive in %v", message, TestChannelTimeout)) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func waitForError(t *testing.T, ch <-chan error, message string) error { |
| 42 | if message != "" { |