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