Add failing tests to truncate code_desc when reporter message truncation is used

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2021-01-05 18:09:51 -05:00
parent 85a002f08c
commit 8c62c5ea69

View file

@ -308,6 +308,10 @@ describe "inspec exec with json formatter" do
_(control_with_message["results"].first["message"]).wont_be :nil?
_(control_with_message["results"].first["message"]).must_equal "expected nil to match /some regex that is expected in the content/"
end
it "reports full code_desc by default" do
_(control_with_message["results"].first["code_desc"]).wont_be :nil?
_(control_with_message["results"].first["code_desc"]).must_equal "File / content is expected to match /some regex that is expected in the content/"
end
end
describe "JSON reporter with reporter-message-truncation set to a number" do
@ -319,6 +323,10 @@ describe "inspec exec with json formatter" do
_(control_with_message["results"].first["message"]).wont_be :nil?
_(control_with_message["results"].first["message"]).must_equal "expected nil to matc[Truncated to 20 characters]"
end
it "reports a truncated code_desc" do
_(control_with_message["results"].first["code_desc"]).wont_be :nil?
_(control_with_message["results"].first["code_desc"]).must_equal "File / content is ex[Truncated to 20 characters]"
end
end
describe "JSON reporter with reporter-message-truncation set to a number and working message" do
@ -329,6 +337,9 @@ describe "inspec exec with json formatter" do
it "does not report a truncated message" do
assert !control_with_message["results"].first["message"].include?("Truncated")
end
it "does not report a truncated code_desc" do
assert !control_with_message["results"].first["code_desc"].include?("Truncated")
end
end
describe "JSON reporter with reporter-message-truncation set to ALL" do
@ -340,6 +351,10 @@ describe "inspec exec with json formatter" do
_(control_with_message["results"].first["message"]).wont_be :nil?
_(control_with_message["results"].first["message"]).must_equal "expected nil to match /some regex that is expected in the content/"
end
it "reports full code_desc" do
_(control_with_message["results"].first["code_desc"]).wont_be :nil?
_(control_with_message["results"].first["code_desc"]).must_equal "File / content is expected to match /some regex that is expected in the content/"
end
end
describe "JSON reporter without setting reporter-backtrace-inclusion" do