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

Function TestRunUpdateForOrgCreateIssueSortsOldestFirst

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

Source from the content-addressed store, hash-verified

276}
277
278func TestRunUpdateForOrgCreateIssueSortsOldestFirst(t *testing.T) {
279 origSearch := searchOrgWorkflowReposFn
280 origPreview := previewOrgRepoUpdatesFn
281 origUpdate := runUpdateForTargetRepoFn
282 origWait := waitForOrgRateLimitFn
283 origCreateIssue := createIssueForOrgRepoFn
284 searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) {
285 return []string{"octo/newer", "octo/older"}, nil
286 }
287 previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) {
288 edited := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
289 if strings.HasSuffix(repo, "older") {
290 edited = time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
291 }
292 return orgRepoPreview{
293 Repo: repo,
294 TotalWorkflows: 1,
295 OldestEdit: edited,
296 Workflows: []orgWorkflowPreview{{
297 Name: "repo-assist",
298 CurrentRef: "v1.0.0",
299 LatestRef: "v1.1.0",
300 }},
301 }, nil
302 }
303 runUpdateForTargetRepoFn = func(ctx context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool) error {
304 t.Fatalf("unexpected update call for %s", targetRepo)
305 return nil
306 }
307 var issuedFor []string
308 createIssueForOrgRepoFn = func(ctx context.Context, preview orgRepoPreview, verbose bool) error {
309 issuedFor = append(issuedFor, preview.Repo)
310 return nil
311 }
312 waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil }
313 defer func() {
314 searchOrgWorkflowReposFn = origSearch
315 previewOrgRepoUpdatesFn = origPreview
316 runUpdateForTargetRepoFn = origUpdate
317 waitForOrgRateLimitFn = origWait
318 createIssueForOrgRepoFn = origCreateIssue
319 }()
320
321 err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{Yes: true}, false, true, false)
322 require.NoError(t, err)
323 assert.Equal(t, []string{"octo/older", "octo/newer"}, issuedFor)
324}
325
326func TestRunUpdateForOrgContinuesAfterPreviewError(t *testing.T) {
327 origSearch := searchOrgWorkflowReposFn

Callers

nothing calls this directly

Calls 2

runUpdateForOrgFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected