Merge pull request #5047 from hirasawayuki/workflow-enable-cmd
Fix disabled_inactivity workflow can be changed to enable
This commit is contained in:
commit
d0c7c4800a
4 changed files with 64 additions and 3 deletions
|
|
@ -67,7 +67,7 @@ func runEnable(opts *EnableOptions) error {
|
|||
return fmt.Errorf("could not determine base repo: %w", err)
|
||||
}
|
||||
|
||||
states := []shared.WorkflowState{shared.DisabledManually}
|
||||
states := []shared.WorkflowState{shared.DisabledManually, shared.DisabledInactivity}
|
||||
workflow, err := shared.ResolveWorkflow(
|
||||
opts.IO, client, repo, opts.Prompt, opts.Selector, states)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -180,6 +180,35 @@ func TestEnableRun(t *testing.T) {
|
|||
},
|
||||
wantOut: "✓ Enabled a disabled workflow\n",
|
||||
},
|
||||
{
|
||||
name: "tty name arg inactivity workflow",
|
||||
opts: &EnableOptions{
|
||||
Selector: "a disabled inactivity workflow",
|
||||
},
|
||||
tty: true,
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/a disabled inactivity workflow"),
|
||||
httpmock.StatusStringResponse(404, "not found"))
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
|
||||
httpmock.JSONResponse(shared.WorkflowsPayload{
|
||||
Workflows: []shared.Workflow{
|
||||
shared.AWorkflow,
|
||||
shared.DisabledInactivityWorkflow,
|
||||
shared.UniqueDisabledWorkflow,
|
||||
shared.AnotherWorkflow,
|
||||
},
|
||||
}))
|
||||
reg.Register(
|
||||
httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/1206/enable"),
|
||||
httpmock.StatusStringResponse(204, "{}"))
|
||||
},
|
||||
askStubs: func(as *prompt.AskStubber) {
|
||||
as.StubOne(1)
|
||||
},
|
||||
wantOut: "✓ Enabled a disabled inactivity workflow\n",
|
||||
},
|
||||
{
|
||||
name: "tty ID arg",
|
||||
opts: &EnableOptions{
|
||||
|
|
@ -235,6 +264,30 @@ func TestEnableRun(t *testing.T) {
|
|||
httpmock.StatusStringResponse(204, "{}"))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nontty name arg inactivity workflow",
|
||||
opts: &EnableOptions{
|
||||
Selector: "a disabled inactivity workflow",
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/a disabled inactivity workflow"),
|
||||
httpmock.StatusStringResponse(404, "not found"))
|
||||
reg.Register(
|
||||
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
|
||||
httpmock.JSONResponse(shared.WorkflowsPayload{
|
||||
Workflows: []shared.Workflow{
|
||||
shared.AWorkflow,
|
||||
shared.DisabledInactivityWorkflow,
|
||||
shared.UniqueDisabledWorkflow,
|
||||
shared.AnotherWorkflow,
|
||||
},
|
||||
}))
|
||||
reg.Register(
|
||||
httpmock.REST("PUT", "repos/OWNER/REPO/actions/workflows/1206/enable"),
|
||||
httpmock.StatusStringResponse(204, "{}"))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nontty name arg nonunique",
|
||||
opts: &EnableOptions{
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Active WorkflowState = "active"
|
||||
DisabledManually WorkflowState = "disabled_manually"
|
||||
Active WorkflowState = "active"
|
||||
DisabledManually WorkflowState = "disabled_manually"
|
||||
DisabledInactivity WorkflowState = "disabled_inactivity"
|
||||
)
|
||||
|
||||
type WorkflowState string
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ var DisabledWorkflow = Workflow{
|
|||
State: DisabledManually,
|
||||
}
|
||||
|
||||
var DisabledInactivityWorkflow = Workflow{
|
||||
Name: "a disabled inactivity workflow",
|
||||
ID: 1206,
|
||||
Path: ".github/workflows/disabledInactivity.yml",
|
||||
State: DisabledInactivity,
|
||||
}
|
||||
|
||||
var AnotherDisabledWorkflow = Workflow{
|
||||
Name: "a disabled workflow",
|
||||
ID: 1213,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue