Add passthrough tests to json reporter.

This commit is contained in:
Alexander Stein 2021-03-11 22:03:50 -05:00
parent a75241fe1d
commit 827ce32eec

View file

@ -1,5 +1,6 @@
require "functional/helper"
require "json_schemer"
require "tempfile"
describe "inspec exec with json formatter" do
include FunctionalHelper
@ -468,4 +469,56 @@ describe "inspec exec with json formatter" do
_(inner_profile_controls.count).must_equal 1
end
end
describe "JSON reporter with a config" do
let(:config_path) do
@file = Tempfile.new("config.json")
@file.write(config_data)
@file.close
@file.path
end
after do
@file.unlink
end
let(:invocation) do
"exec #{complete_profile} --config #{config_path}"
end
let(:run_result) { run_inspec_process(invocation) }
describe "and the config specifies passthrough data" do
let(:config_data) do
<<~END
{
"reporter": {
"json": {
"stdout": true,
"passthrough": {
"a": 1,
"b": false
}
}
}
}
END
end
it "should include passthrough data" do
_(run_result.stderr).must_equal ""
json = JSON.parse(run_result.stdout)
%w{
passthrough
}.each do |field|
_(json.keys).must_include field
end
assert_exit_code 0, run_result
end
end
end
end