MCPcopy Create free account
hub / github.com/cli/cli / TestWaitForWorkflowRun

Function TestWaitForWorkflowRun

acceptance/acceptance_test.go:269–312  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

267}
268
269func TestWaitForWorkflowRun(t *testing.T) {
270 t.Run("returns registered run", func(t *testing.T) {
271 var attempts int
272 var sleeps []time.Duration
273 runID, err := waitForWorkflowRun(func() (string, error) {
274 attempts++
275 if attempts == 3 {
276 return "1234", nil
277 }
278 return "", nil
279 }, func(duration time.Duration) {
280 sleeps = append(sleeps, duration)
281 })
282
283 require.NoError(t, err)
284 assert.Equal(t, "1234", runID)
285 assert.Equal(t, []time.Duration{workflowPollInterval, workflowPollInterval}, sleeps)
286 })
287
288 t.Run("returns list error", func(t *testing.T) {
289 _, err := waitForWorkflowRun(func() (string, error) {
290 return "", errors.New("listing runs")
291 }, func(time.Duration) {
292 t.Fatal("unexpected sleep")
293 })
294
295 require.EqualError(t, err, "listing runs")
296 })
297
298 t.Run("times out", func(t *testing.T) {
299 var attempts int
300 var sleeps int
301 _, err := waitForWorkflowRun(func() (string, error) {
302 attempts++
303 return "", nil
304 }, func(time.Duration) {
305 sleeps++
306 })
307
308 require.EqualError(t, err, "workflow run did not register within 60 seconds")
309 assert.Equal(t, 13, attempts)
310 assert.Equal(t, 12, sleeps)
311 })
312}
313
314func TestWorkflowRunIDFromOutput(t *testing.T) {
315 tests := []struct {

Callers

nothing calls this directly

Calls 3

waitForWorkflowRunFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected