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

Function TestRunUpdateForOrgCreateIssueSkipsWhenDeclined

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

Source from the content-addressed store, hash-verified

84}
85
86func 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
131func TestRunUpdateForOrgDryRun(t *testing.T) {
132 origSearch := searchOrgWorkflowReposFn

Callers

nothing calls this directly

Calls 3

captureUpdateOrgStderrFunction · 0.85
runUpdateForOrgFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected