(t *testing.T)
| 261 | } |
| 262 | |
| 263 | func TestRunUpgradeForOrgCreateIssue(t *testing.T) { |
| 264 | origSearch := searchOrgLockWorkflowReposFn |
| 265 | origScan := scanUpgradeRepoFn |
| 266 | origUpgrade := runUpgradeForTargetRepoFn |
| 267 | origWait := waitForOrgRateLimitFn |
| 268 | origIssue := createIssueForUpgradeOrgRepoFn |
| 269 | searchOrgLockWorkflowReposFn = func(ctx context.Context, org string, verbose bool) ([]string, error) { |
| 270 | return []string{"octo/api", "octo/web"}, nil |
| 271 | } |
| 272 | scanUpgradeRepoFn = mockScanUpgradeRepo |
| 273 | runUpgradeForTargetRepoFn = func(ctx context.Context, repo string, opts upgradeOptions, verbose bool) error { |
| 274 | t.Fatalf("unexpected upgrade call for %s", repo) |
| 275 | return nil |
| 276 | } |
| 277 | var issuedRepos []string |
| 278 | createIssueForUpgradeOrgRepoFn = func(ctx context.Context, repo string, verbose bool) error { |
| 279 | issuedRepos = append(issuedRepos, repo) |
| 280 | return nil |
| 281 | } |
| 282 | waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil } |
| 283 | defer func() { |
| 284 | searchOrgLockWorkflowReposFn = origSearch |
| 285 | scanUpgradeRepoFn = origScan |
| 286 | runUpgradeForTargetRepoFn = origUpgrade |
| 287 | waitForOrgRateLimitFn = origWait |
| 288 | createIssueForUpgradeOrgRepoFn = origIssue |
| 289 | }() |
| 290 | |
| 291 | err := runUpgradeForOrg(context.Background(), "octo", nil, upgradeOptions{ctx: context.Background(), yes: true}, false, true, false) |
| 292 | require.NoError(t, err) |
| 293 | assert.Equal(t, []string{"octo/api", "octo/web"}, issuedRepos) |
| 294 | } |
| 295 | |
| 296 | func TestRunUpgradeCommandCreateIssueRequiresOrg(t *testing.T) { |
| 297 | cmd := NewUpgradeCommand() |
nothing calls this directly
no test coverage detected