(t *testing.T)
| 90 | } |
| 91 | |
| 92 | func 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, "{}")) |
nothing calls this directly
no test coverage detected