diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 37dddf1..8e438e1 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -237,6 +237,12 @@ def runner_options(transport, state = {}, platform = nil, suite = nil) # rubocop # default to false until we default to true in inspec runner_options[:backend_cache] = false end + + if config[:backend] + runner_options[:backend] = config[:backend] + else + runner_options[:backend] = 'ssh' + end end end diff --git a/spec/kitchen/verifier/inspec_spec.rb b/spec/kitchen/verifier/inspec_spec.rb index 4dfd535..969d6a6 100644 --- a/spec/kitchen/verifier/inspec_spec.rb +++ b/spec/kitchen/verifier/inspec_spec.rb @@ -35,6 +35,7 @@ kitchen_root: kitchen_root, test_base_path: File.join(kitchen_root, "test", "integration"), backend_cache: true, + backend: 'gcp', reporter: [ "cli", "junit:path/to/results/%{platform}_%{suite}_inspec.xml", @@ -118,6 +119,27 @@ config = verifier.send(:runner_options, transport) expect(config.to_hash).to include(backend_cache: false) end + + it "inspec version warn for backend_cache" do + config[:backend_cache] = true + stub_const("Inspec::VERSION", "1.46.0") + expect_any_instance_of(Logger).to receive(:warn). + with("backend_cache requires InSpec version >= 1.47.0"). + and_return("captured") + config = verifier.send(:runner_options, transport) + expect(config.to_hash).to include(backend_cache: true) + end + + it 'backend option sets to gcp' do + config = verifier.send(:runner_options, transport) + expect(config.to_hash).to include(backend: 'gcp') + end + + it 'backend option defaults to ssh' do + config[:backend] = nil + config = verifier.send(:runner_options, transport) + expect(config.to_hash).to include(backend: 'ssh') + end end describe "#finalize_config!" do