MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / WaitForChannel

Function WaitForChannel

rest/utilities_testing_async.go:23–39  ·  view source on GitHub ↗
(t *testing.T, ch <-chan error, message string)

Source from the content-addressed store, hash-verified

21const TestChannelTimeout = 30 * time.Second
22
23func 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
41func waitForError(t *testing.T, ch <-chan error, message string) error {
42 if message != "" {

Calls 1

AfterMethod · 0.80