(t *testing.T)
| 267 | } |
| 268 | |
| 269 | func 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 | |
| 314 | func TestWorkflowRunIDFromOutput(t *testing.T) { |
| 315 | tests := []struct { |
nothing calls this directly
no test coverage detected