Fix handling using resources with incompatible resources (eg file + aws).

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-07-18 01:42:14 -07:00
parent 14c245eccb
commit d3df69213b
3 changed files with 17 additions and 1 deletions

View file

@ -165,7 +165,11 @@ module Inspec::Resources
end
def to_s
"File #{source_path}"
if file then
"File #{source_path}"
else
"Bad File on %s" % [inspec.backend.class]
end
end
private

View file

@ -23,6 +23,15 @@ describe "inspec exec" do
skip_windows!
end
it "cleanly fails if mixing incompatible resource and transports" do
# TODO: I do not know how to test this more directly. It should be possible.
inspec "exec -t aws:// #{profile_path}/incompatible_resource_for_transport.rb"
stdout.must_include "Bad File on TrainPlugins::Aws::Connection"
stdout.must_include "Resource `file` is not supported on platform aws/train-aws"
stderr.must_equal ""
end
it "can execute the profile" do
inspec("exec " + example_profile + " --no-create-lockfile")
stderr.must_equal ""

View file

@ -0,0 +1,3 @@
describe file('/tmp/foo') do
it { should exist }
end