(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestRunUpdateForOrgCreateIssueRequiresYesInCI(t *testing.T) { |
| 50 | origSearch := searchOrgWorkflowReposFn |
| 51 | origPreview := previewOrgRepoUpdatesFn |
| 52 | origWait := waitForOrgRateLimitFn |
| 53 | origCreateIssue := createIssueForOrgRepoFn |
| 54 | origIsCI := isRunningInCIFn |
| 55 | searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) { |
| 56 | return []string{"octo/api"}, nil |
| 57 | } |
| 58 | previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) { |
| 59 | return orgRepoPreview{ |
| 60 | Repo: repo, |
| 61 | TotalWorkflows: 1, |
| 62 | Workflows: []orgWorkflowPreview{{ |
| 63 | Name: "repo-assist", CurrentRef: "v1.0.0", LatestRef: "v1.1.0", |
| 64 | }}, |
| 65 | }, nil |
| 66 | } |
| 67 | waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil } |
| 68 | createIssueForOrgRepoFn = func(ctx context.Context, preview orgRepoPreview, verbose bool) error { |
| 69 | t.Fatalf("issue creation should not run in CI without --yes") |
| 70 | return nil |
| 71 | } |
| 72 | isRunningInCIFn = func() bool { return true } |
| 73 | defer func() { |
| 74 | searchOrgWorkflowReposFn = origSearch |
| 75 | previewOrgRepoUpdatesFn = origPreview |
| 76 | waitForOrgRateLimitFn = origWait |
| 77 | createIssueForOrgRepoFn = origCreateIssue |
| 78 | isRunningInCIFn = origIsCI |
| 79 | }() |
| 80 | |
| 81 | err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{}, false, true, false) |
| 82 | require.Error(t, err) |
| 83 | assert.Contains(t, err.Error(), "--yes") |
| 84 | } |
| 85 | |
| 86 | func TestRunUpdateForOrgCreateIssueSkipsWhenDeclined(t *testing.T) { |
| 87 | origSearch := searchOrgWorkflowReposFn |
nothing calls this directly
no test coverage detected