MCPcopy
hub / github.com/uber-go/mock / waitForMocks

Function waitForMocks

sample/concurrent/concurrent_test.go:27–45  ·  view source on GitHub ↗
(ctx context.Context, ctrl *gomock.Controller)

Source from the content-addressed store, hash-verified

25}
26
27func waitForMocks(ctx context.Context, ctrl *gomock.Controller) error {
28 ticker := time.NewTicker(1 * time.Millisecond)
29 defer ticker.Stop()
30
31 timeout := time.After(3 * time.Millisecond)
32
33 for {
34 select {
35 case <-ticker.C:
36 if ctrl.Satisfied() {
37 return nil
38 }
39 case <-timeout:
40 return fmt.Errorf("timeout waiting for mocks to be satisfied")
41 case <-ctx.Done():
42 return fmt.Errorf("context cancelled")
43 }
44 }
45}
46
47// TestConcurrentFails is expected to fail (and is disabled). It
48// demonstrates how to use gomock.WithContext to interrupt the test

Callers 1

Calls 3

AfterMethod · 0.80
ErrorfMethod · 0.65
SatisfiedMethod · 0.45

Tested by

no test coverage detected