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)
| 75 | // waitForWebhookCount blocks until at least n webhooks for (project, eventTitle) |
| 76 | // have arrived, or fails the test after webhookWaitTimeout. |
| 77 | func 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). |
| 94 | func requireWebhookCount(t *testing.T, c *webhookCollector, projectName, eventTitle string, n int) { |
no test coverage detected