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

Function TestRunUpdateForOrgDryRun

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

Source from the content-addressed store, hash-verified

129}
130
131func TestRunUpdateForOrgDryRun(t *testing.T) {
132 origSearch := searchOrgWorkflowReposFn
133 origPreview := previewOrgRepoUpdatesFn
134 origUpdate := runUpdateForTargetRepoFn
135 origWait := waitForOrgRateLimitFn
136 searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) {
137 return []string{"octo/api", "octo/web"}, nil
138 }
139
140 previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) {
141 if repo == "octo/api" {
142 return orgRepoPreview{
143 Repo: repo,
144 TotalWorkflows: 1,
145 OldestEdit: time.Date(2024, 1, 2, 0, 0, 0, 0, time.UTC),
146 Workflows: []orgWorkflowPreview{{
147 Name: "repo-assist",
148 CurrentRef: "v1.0.0",
149 LatestRef: "v1.1.0",
150 }},
151 }, nil
152 }
153 return orgRepoPreview{Repo: repo}, nil
154 }
155 runUpdateForTargetRepoFn = func(ctx context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool) error {
156 t.Fatalf("unexpected update call for %s", targetRepo)
157 return nil
158 }
159 waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil }
160 defer func() {
161 searchOrgWorkflowReposFn = origSearch
162 previewOrgRepoUpdatesFn = origPreview
163 runUpdateForTargetRepoFn = origUpdate
164 waitForOrgRateLimitFn = origWait
165 }()
166
167 output := captureUpdateOrgStderr(t, func() {
168 err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{}, false, false, false)
169 require.NoError(t, err)
170 })
171
172 assert.Contains(t, output, "Dry-run preview of update pull requests")
173 assert.Contains(t, output, "octo/api")
174 assert.Contains(t, output, "octo/api (1 workflow(s))")
175 assert.Contains(t, output, "repo-assist: v1.0.0 -> v1.1.0")
176 assert.NotContains(t, output, "- octo/web\n")
177}
178
179func TestRunUpdateForOrgPassesWorkflowNameFilters(t *testing.T) {
180 origSearch := searchOrgWorkflowReposFn

Callers

nothing calls this directly

Calls 3

captureUpdateOrgStderrFunction · 0.85
runUpdateForOrgFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected