Added test to catch the control execution issue while using controls option

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
Vasu1105 2021-03-17 20:00:15 +05:30
parent 2f41c16ad4
commit 6853f6450e
2 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,19 @@
control "foo" do
describe 'a thing' do
it { should cmp 'a thing' }
end
end
control "bar" do
puts 'Control block executed'
describe 'a thing' do
it { should cmp 'a thing' }
end
end
control "baz" do
puts 'Control block executed'
describe 'a thing' do
it { should cmp 'a thing' }
end
end

View file

@ -178,6 +178,15 @@ Test Summary: 0 successful, 0 failures, 0 skipped
assert_exit_code 100, out
end
it "executes only specified controls when selecting the controls by literal names" do
inspec("exec " + File.join(profile_path, "filter_table") + " --no-create-lockfile --controls foo")
_(stdout).must_include "\nProfile Summary: 1 successful controls, 0 control failures, 0 controls skipped\n"
_(stderr).must_equal ""
assert_exit_code 0, out
end
it "executes only specified controls when selecting passing controls by literal names" do
inspec("exec " + File.join(profile_path, "filter_table") + " --no-create-lockfile --controls 2943_pass_undeclared_field_in_hash 2943_pass_irregular_row_key")