MCPcopy Index your code
hub / github.com/cli/cli / TestDisableRun

Function TestDisableRun

pkg/cmd/workflow/disable/disable_test.go:92–293  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestDisableRun(t *testing.T) {
93 tests := []struct {
94 name string
95 opts *DisableOptions
96 httpStubs func(*httpmock.Registry)
97 promptStubs func(*prompter.MockPrompter)
98 tty bool
99 wantOut string
100 wantErrOut string
101 wantErr bool
102 }{
103 {
104 name: "tty no arg",
105 opts: &DisableOptions{
106 Prompt: true,
107 },
108 tty: true,
109 httpStubs: func(reg *httpmock.Registry) {
110 reg.Register(
111 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
112 httpmock.JSONResponse(shared.WorkflowsPayload{
113 Workflows: []shared.Workflow{
114 shared.AWorkflow,
115 shared.DisabledWorkflow,
116 shared.AnotherWorkflow,
117 },
118 }))
119 reg.Register(
120 httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/789/disable"),
121 httpmock.StatusStringResponse(204, "{}"))
122 },
123 promptStubs: func(pm *prompter.MockPrompter) {
124 pm.RegisterSelect("Select a workflow", []string{"a workflow (flow.yml)", "another workflow (another.yml)"}, func(_, _ string, opts []string) (int, error) {
125 return prompter.IndexFor(opts, "another workflow (another.yml)")
126 })
127 },
128 wantOut: "✓ Disabled another workflow\n",
129 },
130 {
131 name: "tty name arg",
132 opts: &DisableOptions{
133 Selector: "a workflow",
134 },
135 tty: true,
136 httpStubs: func(reg *httpmock.Registry) {
137 reg.Register(
138 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
139 httpmock.JSONResponse(shared.WorkflowsPayload{
140 Workflows: []shared.Workflow{
141 shared.AWorkflow,
142 shared.DisabledWorkflow,
143 shared.AnotherWorkflow,
144 },
145 }))
146 reg.Register(
147 httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/123/disable"),
148 httpmock.StatusStringResponse(204, "{}"))
149 },

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
StatusStringResponseFunction · 0.92
IndexForFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
NewMockPrompterFunction · 0.92
runDisableFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected