21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-02 17:00:49 +02:00

Log an error when a system command doesnt have an exit status.

Occurred at least 1 time with a check_http.
This commit is contained in:
Colin Darie 2018-07-06 12:58:25 +02:00
parent 4d42c34f4f
commit d98c1241c5
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 11 additions and 1 deletions

View file

@ -22,7 +22,7 @@ class CheckLogger
check_log.exit_status = result.exit_status
check_log.raw_response = result.stdout
if result.exit_status > 0 # rubocop:disable Style/NumericPredicate
if result.exit_status.nil? || result.exit_status > 0 # rubocop:disable Style/NumericPredicate
check_log.error = result.stderr
check_log.status = :failed
end

View file

@ -39,6 +39,16 @@ class CheckLoggerTest < ActiveSupport::TestCase
assert @logger.check_log.failed?
end
test "should log an error when there is not exit status" do
result = SystemCommandResult.new("command", nil, nil, "an error")
@logger.log :after_command, result
assert_nil @logger.check_log.raw_response
assert_equal "an error", @logger.check_log.error
assert_nil @logger.check_log.exit_status
assert @logger.check_log.failed?
end
test "should log a successful parsed response" do
response = OpenStruct.new(
domain: "example.fr",