mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
Add passthrough tests to json reporter.
This commit is contained in:
parent
a75241fe1d
commit
827ce32eec
1 changed files with 53 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue