MCPcopy Create free account
hub / github.com/github/gh-aw / TestRunUpdateForOrgStopsOnCancellation

Function TestRunUpdateForOrgStopsOnCancellation

pkg/cli/update_org_test.go:421–461  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

419}
420
421func TestRunUpdateForOrgStopsOnCancellation(t *testing.T) {
422 origSearch := searchOrgWorkflowReposFn
423 origPreview := previewOrgRepoUpdatesFn
424 origUpdate := runUpdateForTargetRepoFn
425 origWait := waitForOrgRateLimitFn
426 searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) {
427 return []string{"octo/a", "octo/b"}, nil
428 }
429 ctx, cancel := context.WithCancel(context.Background())
430 previewOrgRepoUpdatesFn = func(c context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) {
431 // Cancel after the first repo is previewed.
432 cancel()
433 return orgRepoPreview{
434 Repo: repo,
435 TotalWorkflows: 1,
436 Workflows: []orgWorkflowPreview{{
437 Name: "repo-assist",
438 CurrentRef: "v1.0.0",
439 LatestRef: "v1.1.0",
440 }},
441 }, nil
442 }
443 runUpdateForTargetRepoFn = func(c context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool) error {
444 return nil
445 }
446 waitForOrgRateLimitFn = func(c context.Context, resource string, verbose bool) error { return nil }
447 defer func() {
448 searchOrgWorkflowReposFn = origSearch
449 previewOrgRepoUpdatesFn = origPreview
450 runUpdateForTargetRepoFn = origUpdate
451 waitForOrgRateLimitFn = origWait
452 }()
453
454 output := captureUpdateOrgStderr(t, func() {
455 err := runUpdateForOrg(ctx, "octo", nil, UpdateWorkflowsOptions{}, false, false, false)
456 require.NoError(t, err)
457 })
458
459 assert.Contains(t, output, "Cancellation requested")
460 assert.Contains(t, output, "- octo/a")
461}
462
463func TestRunUpdateForOrgCreateIssueReturnsErrorWhenAllIssueCreatesFail(t *testing.T) {
464 origSearch := searchOrgWorkflowReposFn

Callers

nothing calls this directly

Calls 3

captureUpdateOrgStderrFunction · 0.85
runUpdateForOrgFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected