(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestRunUpdateForOrgCreateIssueSkipsWhenDeclined(t *testing.T) { |
| 87 | origSearch := searchOrgWorkflowReposFn |
| 88 | origPreview := previewOrgRepoUpdatesFn |
| 89 | origWait := waitForOrgRateLimitFn |
| 90 | origCreateIssue := createIssueForOrgRepoFn |
| 91 | origConfirm := orgConfirmActionFn |
| 92 | origIsCI := isRunningInCIFn |
| 93 | searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) { |
| 94 | return []string{"octo/api"}, nil |
| 95 | } |
| 96 | previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) { |
| 97 | return orgRepoPreview{ |
| 98 | Repo: repo, |
| 99 | TotalWorkflows: 1, |
| 100 | Workflows: []orgWorkflowPreview{{ |
| 101 | Name: "repo-assist", CurrentRef: "v1.0.0", LatestRef: "v1.1.0", |
| 102 | }}, |
| 103 | }, nil |
| 104 | } |
| 105 | waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil } |
| 106 | createIssueForOrgRepoFn = func(ctx context.Context, preview orgRepoPreview, verbose bool) error { |
| 107 | t.Fatalf("issue creation should be skipped when confirmation is declined") |
| 108 | return nil |
| 109 | } |
| 110 | orgConfirmActionFn = func(title, affirmative, negative string) (bool, error) { return false, nil } |
| 111 | isRunningInCIFn = func() bool { return false } |
| 112 | defer func() { |
| 113 | searchOrgWorkflowReposFn = origSearch |
| 114 | previewOrgRepoUpdatesFn = origPreview |
| 115 | waitForOrgRateLimitFn = origWait |
| 116 | createIssueForOrgRepoFn = origCreateIssue |
| 117 | orgConfirmActionFn = origConfirm |
| 118 | isRunningInCIFn = origIsCI |
| 119 | }() |
| 120 | |
| 121 | output := captureUpdateOrgStderr(t, func() { |
| 122 | err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{}, false, true, false) |
| 123 | require.NoError(t, err) |
| 124 | }) |
| 125 | |
| 126 | assert.Contains(t, output, "Repository: octo/api") |
| 127 | assert.Contains(t, output, "repo-assist: v1.0.0 -> v1.1.0") |
| 128 | assert.Contains(t, output, "Skipped octo/api") |
| 129 | } |
| 130 | |
| 131 | func TestRunUpdateForOrgDryRun(t *testing.T) { |
| 132 | origSearch := searchOrgWorkflowReposFn |
nothing calls this directly
no test coverage detected