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

Function TestRunUpgradeForOrgDryRun

pkg/cli/upgrade_org_test.go:145–174  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestRunUpgradeForOrgDryRun(t *testing.T) {
146 origSearch := searchOrgLockWorkflowReposFn
147 origScan := scanUpgradeRepoFn
148 origUpgrade := runUpgradeForTargetRepoFn
149 origWait := waitForOrgRateLimitFn
150 searchOrgLockWorkflowReposFn = func(ctx context.Context, org string, verbose bool) ([]string, error) {
151 return []string{"octo/api", "octo/web"}, nil
152 }
153 scanUpgradeRepoFn = mockScanUpgradeRepo
154 runUpgradeForTargetRepoFn = func(ctx context.Context, repo string, opts upgradeOptions, verbose bool) error {
155 t.Fatalf("unexpected upgrade call for %s", repo)
156 return nil
157 }
158 waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil }
159 defer func() {
160 searchOrgLockWorkflowReposFn = origSearch
161 scanUpgradeRepoFn = origScan
162 runUpgradeForTargetRepoFn = origUpgrade
163 waitForOrgRateLimitFn = origWait
164 }()
165
166 output := captureUpgradeOrgStderr(t, func() {
167 err := runUpgradeForOrg(context.Background(), "octo", nil, upgradeOptions{ctx: context.Background()}, false, false, false)
168 require.NoError(t, err)
169 })
170
171 assert.Contains(t, output, "Dry-run preview of upgrade pull requests")
172 assert.Contains(t, output, "octo/api")
173 assert.Contains(t, output, "octo/web")
174}
175
176func TestRunUpgradeForOrgDryRunShowsVersion(t *testing.T) {
177 origSearch := searchOrgLockWorkflowReposFn

Callers

nothing calls this directly

Calls 3

captureUpgradeOrgStderrFunction · 0.85
runUpgradeForOrgFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected