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

Function TestRunUpdateForOrgCreatePRSortsOldestFirst

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

Source from the content-addressed store, hash-verified

234}
235
236func TestRunUpdateForOrgCreatePRSortsOldestFirst(t *testing.T) {
237 origSearch := searchOrgWorkflowReposFn
238 origPreview := previewOrgRepoUpdatesFn
239 origUpdate := runUpdateForTargetRepoFn
240 origWait := waitForOrgRateLimitFn
241 searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) {
242 return []string{"octo/newer", "octo/older"}, nil
243 }
244 previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) {
245 edited := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
246 if strings.HasSuffix(repo, "older") {
247 edited = time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
248 }
249 return orgRepoPreview{
250 Repo: repo,
251 TotalWorkflows: 1,
252 OldestEdit: edited,
253 Workflows: []orgWorkflowPreview{{
254 Name: "repo-assist",
255 CurrentRef: "v1.0.0",
256 LatestRef: "v1.1.0",
257 }},
258 }, nil
259 }
260 var processed []string
261 runUpdateForTargetRepoFn = func(ctx context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool) error {
262 processed = append(processed, targetRepo)
263 return nil
264 }
265 waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil }
266 defer func() {
267 searchOrgWorkflowReposFn = origSearch
268 previewOrgRepoUpdatesFn = origPreview
269 runUpdateForTargetRepoFn = origUpdate
270 waitForOrgRateLimitFn = origWait
271 }()
272
273 err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{Yes: true}, true, false, false)
274 require.NoError(t, err)
275 assert.Equal(t, []string{"octo/older", "octo/newer"}, processed)
276}
277
278func TestRunUpdateForOrgCreateIssueSortsOldestFirst(t *testing.T) {
279 origSearch := searchOrgWorkflowReposFn

Callers

nothing calls this directly

Calls 2

runUpdateForOrgFunction · 0.85
BackgroundMethod · 0.80

Tested by

no test coverage detected