mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Various checks in the start domain action were accidentally causing a redefine right after initial create. Update to provide debug output when the domain needs to be changed to allow capture of the redefines occurring in the future and to make it easy for the tests to pick up where the redefine was triggered by setting an expectation on the log output. Include a small fix to avoid running strip on what might be a nil object returned for elements without any text attributes. Fix a bug where changes to tpm settings made to the config after an initial domain creation where there was previously no tpm defined, would be ignored. Adds a logger double and updates other tests that trigger log calls. should fix #1176
33 lines
1.0 KiB
Ruby
33 lines
1.0 KiB
Ruby
require 'fog/libvirt'
|
|
|
|
shared_context 'libvirt' do
|
|
include_context 'unit'
|
|
|
|
let(:libvirt_context) { true }
|
|
let(:id) { 'dummy-vagrant_dummy' }
|
|
let(:connection) { double('connection') }
|
|
let(:domain) { double('domain') }
|
|
let(:logger) { double('logger') }
|
|
|
|
def connection_result(options = {})
|
|
result = options.fetch(:result, nil)
|
|
double('connection_result' => result)
|
|
end
|
|
|
|
before (:each) do
|
|
# we don't want unit tests to ever run commands on the system; so we wire
|
|
# in a double to ensure any unexpected messages raise exceptions
|
|
stub_const('::Fog::Compute', connection)
|
|
|
|
# drivers also call vm_exists? during init;
|
|
allow(connection).to receive(:servers).with(kind_of(String))
|
|
.and_return(connection_result(result: nil))
|
|
|
|
# return some information for domain when needed
|
|
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
|
|
|
|
allow(machine).to receive(:id).and_return(id)
|
|
allow(Log4r::Logger).to receive(:new).and_return(logger)
|
|
end
|
|
end
|