(t *testing.T)
| 324 | } |
| 325 | |
| 326 | func TestRunUpdateForOrgContinuesAfterPreviewError(t *testing.T) { |
| 327 | origSearch := searchOrgWorkflowReposFn |
| 328 | origPreview := previewOrgRepoUpdatesFn |
| 329 | origUpdate := runUpdateForTargetRepoFn |
| 330 | origWait := waitForOrgRateLimitFn |
| 331 | searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) { |
| 332 | return []string{"octo/broken", "octo/good"}, nil |
| 333 | } |
| 334 | previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) { |
| 335 | if repo == "octo/broken" { |
| 336 | return orgRepoPreview{}, errors.New("failed to parse frontmatter") |
| 337 | } |
| 338 | return orgRepoPreview{ |
| 339 | Repo: repo, |
| 340 | TotalWorkflows: 1, |
| 341 | Workflows: []orgWorkflowPreview{{ |
| 342 | Name: "repo-assist", |
| 343 | CurrentRef: "v1.0.0", |
| 344 | LatestRef: "v1.1.0", |
| 345 | }}, |
| 346 | }, nil |
| 347 | } |
| 348 | runUpdateForTargetRepoFn = func(ctx context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool) error { |
| 349 | t.Fatalf("unexpected update call for %s", targetRepo) |
| 350 | return nil |
| 351 | } |
| 352 | waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil } |
| 353 | defer func() { |
| 354 | searchOrgWorkflowReposFn = origSearch |
| 355 | previewOrgRepoUpdatesFn = origPreview |
| 356 | runUpdateForTargetRepoFn = origUpdate |
| 357 | waitForOrgRateLimitFn = origWait |
| 358 | }() |
| 359 | |
| 360 | output := captureUpdateOrgStderr(t, func() { |
| 361 | err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{}, false, false, false) |
| 362 | require.NoError(t, err) |
| 363 | }) |
| 364 | |
| 365 | // The broken repo must be skipped (not abort the run), and the good repo reported. |
| 366 | assert.Contains(t, output, "Skipping octo/broken") |
| 367 | assert.Contains(t, output, "- octo/good") |
| 368 | assert.Contains(t, output, "repo-assist: v1.0.0 -> v1.1.0") |
| 369 | } |
| 370 | |
| 371 | func TestRunUpdateForOrgStopsOnCriticalRateLimit(t *testing.T) { |
| 372 | origSearch := searchOrgWorkflowReposFn |
nothing calls this directly
no test coverage detected