mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Configurable backend for Chef Infra in Target Mode (#7058)
* Add configurable InSpec backend for Chef Infra Signed-off-by: Thomas Heinen <thomasheinen@gmail.com> * Add changing backend for Chef Infra Signed-off-by: Thomas Heinen <thomasheinen@gmail.com> * Add test * Fix typo on test Signed-off-by: Thomas Heinen <thomasheinen@gmail.com> * Fix test Signed-off-by: Thomas Heinen <thomasheinen@gmail.com> --------- Signed-off-by: Thomas Heinen <thomasheinen@gmail.com>
This commit is contained in:
parent
9bca50c428
commit
ea7e386028
2 changed files with 25 additions and 2 deletions
|
@ -89,7 +89,12 @@ module Inspec
|
|||
end
|
||||
|
||||
def configure_transport
|
||||
@backend = Inspec::Backend.create(@conf)
|
||||
backend = Inspec::Backend.create(@conf)
|
||||
set_backend(backend)
|
||||
end
|
||||
|
||||
def set_backend(new_backend)
|
||||
@backend = new_backend
|
||||
@test_collector.backend = @backend
|
||||
end
|
||||
|
||||
|
|
|
@ -105,4 +105,22 @@ describe Inspec::Runner do
|
|||
_(backend.backend.cache_enabled?(:command)).must_equal false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# =============================================================== #
|
||||
# Backend Switching
|
||||
# =============================================================== #
|
||||
|
||||
describe "when backend gets switched" do
|
||||
it "replaces the existing backend with the given one" do
|
||||
opts = { command_runner: :generic, backend_cache: false }
|
||||
runner = Inspec::Runner.new(opts)
|
||||
|
||||
new_backend_config = Inspec::Config.new(backend_cache: true)
|
||||
new_backend = Inspec::Backend.create(new_backend_config)
|
||||
runner.set_backend(new_backend)
|
||||
|
||||
active_backend = runner.instance_variable_get(:@backend)
|
||||
_(active_backend.backend).must_be_same_as(new_backend.backend)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue