MCPcopy Index your code
hub / github.com/bytebase/bytebase / waitForWebhookCount

Function waitForWebhookCount

backend/tests/webhook_helpers_test.go:77–91  ·  view source on GitHub ↗

waitForWebhookCount blocks until at least n webhooks for (project, eventTitle) have arrived, or fails the test after webhookWaitTimeout.

(t *testing.T, c *webhookCollector, projectName, eventTitle string, n int)

Source from the content-addressed store, hash-verified

75// waitForWebhookCount blocks until at least n webhooks for (project, eventTitle)
76// have arrived, or fails the test after webhookWaitTimeout.
77func waitForWebhookCount(t *testing.T, c *webhookCollector, projectName, eventTitle string, n int) {
78 t.Helper()
79 deadline := time.Now().Add(webhookWaitTimeout)
80 for {
81 count := countWebhooksFor(c, projectName, eventTitle)
82 if count >= n {
83 return
84 }
85 if time.Now().After(deadline) {
86 t.Fatalf("timed out waiting for %d %q webhooks on %s; got %d after %s",
87 n, eventTitle, projectName, count, webhookWaitTimeout)
88 }
89 time.Sleep(100 * time.Millisecond)
90 }
91}
92
93// requireWebhookCount asserts the exact count of webhooks for (project, eventTitle).
94func requireWebhookCount(t *testing.T, c *webhookCollector, projectName, eventTitle string, n int) {

Callers 1

TestWebhookIntegrationFunction · 0.85

Calls 2

countWebhooksForFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected