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

Function TestEnableRun

pkg/cmd/workflow/enable/enable_test.go:92–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestEnableRun(t *testing.T) {
93 tests := []struct {
94 name string
95 opts *EnableOptions
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: &EnableOptions{
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/456/enable"),
121 httpmock.StatusStringResponse(204, "{}"))
122 },
123 promptStubs: func(pm *prompter.MockPrompter) {
124 pm.RegisterSelect("Select a workflow", []string{"a disabled workflow (disabled.yml)"}, func(_, _ string, opts []string) (int, error) {
125 return prompter.IndexFor(opts, "a disabled workflow (disabled.yml)")
126 })
127 },
128 wantOut: "✓ Enabled a disabled workflow\n",
129 },
130 {
131 name: "tty name arg",
132 opts: &EnableOptions{
133 Selector: "terrible 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.UniqueDisabledWorkflow,
144 shared.AnotherWorkflow,
145 },
146 }))
147 reg.Register(
148 httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/1314/enable"),
149 httpmock.StatusStringResponse(204, "{}"))

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
runEnableFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected