MCPcopy
hub / github.com/livekit/livekit / WithTimeout

Function WithTimeout

pkg/testutils/timeout.go:27–48  ·  view source on GitHub ↗
(t *testing.T, f func() string, timeouts ...time.Duration)

Source from the content-addressed store, hash-verified

25)
26
27func WithTimeout(t *testing.T, f func() string, timeouts ...time.Duration) {
28 timeout := ConnectTimeout
29 if len(timeouts) > 0 {
30 timeout = timeouts[0]
31 }
32 ctx, cancel := context.WithTimeout(context.Background(), timeout)
33 defer cancel()
34 lastErr := ""
35 for {
36 select {
37 case <-ctx.Done():
38 if lastErr != "" {
39 t.Fatalf("did not reach expected state after %v: %s", timeout, lastErr)
40 }
41 case <-time.After(10 * time.Millisecond):
42 lastErr = f()
43 if lastErr == "" {
44 return
45 }
46 }
47 }
48}

Callers 15

TestActiveSpeakersFunction · 0.92
TestDisableCodecsFunction · 0.92
TestStreamTrackerFunction · 0.92
TestAgentsFunction · 0.92
TestAgentNamespacesFunction · 0.92
TestAgentMultiNodeFunction · 0.92
scenarioDataPublishFunction · 0.92

Calls 1

DoneMethod · 0.80

Tested by 15

TestActiveSpeakersFunction · 0.74
TestDisableCodecsFunction · 0.74
TestStreamTrackerFunction · 0.74
TestAgentsFunction · 0.74
TestAgentNamespacesFunction · 0.74
TestAgentMultiNodeFunction · 0.74
TestWebhooksFunction · 0.74
TestMultiNodeRoutingFunction · 0.74