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:
parent
4d42c34f4f
commit
d98c1241c5
|
@ -22,7 +22,7 @@ class CheckLogger
|
||||||
check_log.exit_status = result.exit_status
|
check_log.exit_status = result.exit_status
|
||||||
check_log.raw_response = result.stdout
|
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.error = result.stderr
|
||||||
check_log.status = :failed
|
check_log.status = :failed
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,6 +39,16 @@ class CheckLoggerTest < ActiveSupport::TestCase
|
||||||
assert @logger.check_log.failed?
|
assert @logger.check_log.failed?
|
||||||
end
|
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
|
test "should log a successful parsed response" do
|
||||||
response = OpenStruct.new(
|
response = OpenStruct.new(
|
||||||
domain: "example.fr",
|
domain: "example.fr",
|
||||||
|
|
Loading…
Reference in a new issue