Skip to content

Commit

Permalink
Merge pull request #148 from rundeck/issue/147
Browse files Browse the repository at this point in the history
Fix `jobs unschedule` disables execution
  • Loading branch information
gschueler authored Feb 28, 2018
2 parents a9600cf + 759c5bd commit f35d344
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/rundeck/client/tool/commands/Jobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,20 @@ public boolean disable(DisableOpts options, CommandOutput output) throws IOExcep
return simpleJobApiCall(RundeckApi::jobExecutionDisable, options, output, "Disabled Job %s");
}

@CommandLineInterface(application = "enableSchedule") interface EnableSchedOpts extends ToggleOpts {
@CommandLineInterface(application = "reschedule") interface EnableSchedOpts extends ToggleOpts {
}

@Command(description = "Enable schedule for a job")
public boolean reschedule(EnableSchedOpts options, CommandOutput output) throws IOException, InputError {
return simpleJobApiCall(RundeckApi::jobScheduleEnable, options, output, "Enabled Schedule for Job %s");
}

@CommandLineInterface(application = "disableSchedule") interface DisableSchedOpts extends ToggleOpts {
@CommandLineInterface(application = "unschedule") interface DisableSchedOpts extends ToggleOpts {
}

@Command(description = "Disable schedule for a job")
public boolean unschedule(DisableSchedOpts options, CommandOutput output) throws IOException, InputError {
return simpleJobApiCall(RundeckApi::jobExecutionDisable, options, output, "Disabled Schedule for Job %s");
return simpleJobApiCall(RundeckApi::jobScheduleDisable, options, output, "Disabled Schedule for Job %s");
}

private boolean simpleJobApiCall(
Expand Down
54 changes: 54 additions & 0 deletions src/test/groovy/org/rundeck/client/tool/commands/JobsSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,60 @@ class JobsSpec extends Specification {
null | null | 'a' | 'b/c'
}

@Unroll
def "jobs #action behavior"() {
given:
def api = Mock(RundeckApi)
def deets = [
enable : [
opt : Jobs.EnableOpts,
call: "jobExecutionEnable"
],

disable : [
opt : Jobs.DisableOpts,
call: "jobExecutionDisable"
],

reschedule: [
opt : Jobs.EnableSchedOpts,
call: "jobScheduleEnable"
],

unschedule: [
opt : Jobs.DisableSchedOpts,
call: "jobScheduleDisable"
]
]
Class optClass = deets[action].opt
def apiCall = deets[action].call
def opts = Mock(optClass) {
isId() >> true
getId() >> '123'
getProject() >> 'testProj'
}
def retrofit = new Retrofit.Builder().baseUrl('http://example.com/fake/').build()
def client = new Client(api, retrofit, null, null, 17, true, null)
def hasclient = Mock(RdApp) {
getClient() >> client
}
Jobs jobs = new Jobs(hasclient)
def out = Mock(CommandOutput)
when:
jobs."$action"(opts, out)

then:
1 * api."$apiCall"('123') >> Calls.response(new Simple(success: true))
0 * api._(*_)

where:
action | _
'enable' | _
'disable' | _
'unschedule' | _
'reschedule' | _
}


@Unroll
def "job purge with job #job group #group jobexact #jobexact groupexact #groupexact"() {
Expand Down

0 comments on commit f35d344

Please sign in to comment.