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

Function TestRunUpdateForOrgCreateIssueRequiresYesInCI

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

Source from the content-addressed store, hash-verified

47}
48
49func TestRunUpdateForOrgCreateIssueRequiresYesInCI(t *testing.T) {
50 origSearch := searchOrgWorkflowReposFn
51 origPreview := previewOrgRepoUpdatesFn
52 origWait := waitForOrgRateLimitFn
53 origCreateIssue := createIssueForOrgRepoFn
54 origIsCI := isRunningInCIFn
55 searchOrgWorkflowReposFn = func(ctx context.Context, org string, workflowNames []string, verbose bool) ([]string, error) {
56 return []string{"octo/api"}, nil
57 }
58 previewOrgRepoUpdatesFn = func(ctx context.Context, repo string, opts UpdateWorkflowsOptions, verbose bool) (orgRepoPreview, error) {
59 return orgRepoPreview{
60 Repo: repo,
61 TotalWorkflows: 1,
62 Workflows: []orgWorkflowPreview{{
63 Name: "repo-assist", CurrentRef: "v1.0.0", LatestRef: "v1.1.0",
64 }},
65 }, nil
66 }
67 waitForOrgRateLimitFn = func(ctx context.Context, resource string, verbose bool) error { return nil }
68 createIssueForOrgRepoFn = func(ctx context.Context, preview orgRepoPreview, verbose bool) error {
69 t.Fatalf("issue creation should not run in CI without --yes")
70 return nil
71 }
72 isRunningInCIFn = func() bool { return true }
73 defer func() {
74 searchOrgWorkflowReposFn = origSearch
75 previewOrgRepoUpdatesFn = origPreview
76 waitForOrgRateLimitFn = origWait
77 createIssueForOrgRepoFn = origCreateIssue
78 isRunningInCIFn = origIsCI
79 }()
80
81 err := runUpdateForOrg(context.Background(), "octo", nil, UpdateWorkflowsOptions{}, false, true, false)
82 require.Error(t, err)
83 assert.Contains(t, err.Error(), "--yes")
84}
85
86func TestRunUpdateForOrgCreateIssueSkipsWhenDeclined(t *testing.T) {
87 origSearch := searchOrgWorkflowReposFn

Callers

nothing calls this directly

Calls 3

runUpdateForOrgFunction · 0.85
BackgroundMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected