Skip to content

Commit

Permalink
Merge pull request #172 from anotherchrisberry/cron-messages
Browse files Browse the repository at this point in the history
include description on successful cron validation
  • Loading branch information
ajordens committed Jan 7, 2016
2 parents ca157da + a07e1d1 commit 6364f1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class CronService {
}

try {
echoService.validateCronExpression(cronExpression)
return [ valid: true ]
Map validationResult = echoService.validateCronExpression(cronExpression)
return [ valid: true, description: validationResult.description ]
} catch (RetrofitError e) {
if (e.response?.status == 400) {
Map responseBody = e.getBodyAs(Map) as Map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ class CronServiceSpec extends Specification {
)

expect:
service.validateCronExpression("totally invalid cron expression") == [ valid: true ]
service.validateCronExpression("totally invalid cron expression") == [ valid: true, description: null ]
}

void "should include description if present when validation is successful"() {
def response = [
description: "LGTM"
]
def service = new CronService(
echoService: Mock(EchoService) {
1 * validateCronExpression("1 1 1 1 1 1") >> response
}
)

expect:
service.validateCronExpression("1 1 1 1 1 1") == [ valid: true, description: 'LGTM' ]
}
}

0 comments on commit 6364f1d

Please sign in to comment.