mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Fix assert_invalid in configuration spec
assert_invalid was previously only raising an error if there was a validation error logged, rather than if there wasn't an error. Tests that expected validation failures were passing without any validation errors being logged.
This commit is contained in:
parent
772c38a2b3
commit
7b968c7a72
@ -8,7 +8,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|||||||
|
|
||||||
def assert_invalid
|
def assert_invalid
|
||||||
errors = subject.validate(machine)
|
errors = subject.validate(machine)
|
||||||
raise "No errors: #{errors.inspect}" if errors.values.any? { |v| !v.empty? }
|
raise "No errors: #{errors.inspect}" if errors.values.all?(&:empty?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_valid
|
def assert_valid
|
||||||
@ -21,31 +21,31 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|||||||
assert_valid
|
assert_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid if relative path used for disk' do
|
context 'with disks defined' do
|
||||||
subject.storage :file, path: '../path/to/file.qcow2'
|
before { expect(machine).to receive(:provider_config).and_return(subject).at_least(:once) }
|
||||||
assert_valid
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be invalid if absolute path used for disk' do
|
it 'is valid if relative path used for disk' do
|
||||||
subject.storage :file, path: '/absolute/path/to/file.qcow2'
|
subject.storage :file, path: '../path/to/file.qcow2'
|
||||||
assert_invalid
|
assert_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be invalid if absolute path used for disk' do
|
||||||
|
subject.storage :file, path: '/absolute/path/to/file.qcow2'
|
||||||
|
assert_invalid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with mac defined' do
|
context 'with mac defined' do
|
||||||
let (:vm) { double('vm') }
|
let (:vm) { double('vm') }
|
||||||
let (:networks) { double('networks') }
|
before { expect(machine.config).to receive(:vm).and_return(vm) }
|
||||||
before do
|
|
||||||
allow(vm).to receive(:networks).and_return(networks)
|
|
||||||
allow(machine.config).to receive(:vm).and_return(vm)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is valid with valid mac' do
|
it 'is valid with valid mac' do
|
||||||
allow(networks).to receive(:each).and_return([:public, { mac: 'aa:bb:cc:dd:ee:ff' }])
|
expect(vm).to receive(:networks).and_return([[:public, { mac: 'aa:bb:cc:dd:ee:ff' }]])
|
||||||
assert_valid
|
assert_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be invalid if MAC not formatted correctly' do
|
it 'should be invalid if MAC not formatted correctly' do
|
||||||
allow(networks).to receive(:each).and_return([:public, { mac: 'aabbccddeeff' }])
|
expect(vm).to receive(:networks).and_return([[:public, { mac: 'aabbccddeeff' }]])
|
||||||
assert_invalid
|
assert_invalid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user