Add functional tests for resource_id

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2022-03-04 10:22:01 -05:00
parent edf019b0df
commit fb25c547d0
4 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,5 @@
control "basic custom resource" do
describe basic do
its("resource_id") { should cmp "42" }
end
end

View file

@ -0,0 +1,10 @@
name: resource_ids
title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: you@example.com
license: Apache-2.0
summary: An InSpec Compliance Profile
version: 0.1.0
supports:
platform: os

View file

@ -0,0 +1,7 @@
class Basic < Inspec.resource(1)
name 'basic'
def resource_id
super("42")
end
end

View file

@ -1299,4 +1299,13 @@ EOT
end
end
describe "when evalutating profiles that reference resource_id" do
let(:run_result) { run_inspec_process("exec #{profile}", json: true) }
let(:profile) { "#{profile_path}/resource_ids" } # A profile with custom resources and test controls that exercise resource ids
it "should evaluate all test controls correctly" do
_(run_result.stderr).must_be_empty
assert_json_controls_passing
end
end
end