mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
added test for nil volume (verified that it fails without the bugfix)
This commit is contained in:
@@ -32,9 +32,7 @@ module VagrantPlugins
|
|||||||
)
|
)
|
||||||
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
||||||
root_disk = domain.volumes.select do |x|
|
root_disk = domain.volumes.select do |x|
|
||||||
!x.nil?
|
!x.nil? && x.name == libvirt_domain.name + '.img'
|
||||||
end.select do |x|
|
|
||||||
x.name == libvirt_domain.name + '.img'
|
|
||||||
end.first
|
end.first
|
||||||
raise Errors::NoDomainVolume if root_disk.nil?
|
raise Errors::NoDomainVolume if root_disk.nil?
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,31 @@ describe VagrantPlugins::ProviderLibvirt::Action::PackageDomain do
|
|||||||
expect(File.exist?(File.join(temp_dir, 'Vagrantfile'))).to eq(true)
|
expect(File.exist?(File.join(temp_dir, 'Vagrantfile'))).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with nil volume' do
|
||||||
|
let(:root_disk) { double('libvirt_domain_disk') }
|
||||||
|
before do
|
||||||
|
allow(root_disk).to receive(:name).and_return('default_domain.img')
|
||||||
|
allow(domain).to receive(:volumes).and_return([nil, root_disk])
|
||||||
|
allow(libvirt_domain).to receive(:name).and_return('default_domain')
|
||||||
|
allow(subject).to receive(:download_image).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should succeed' do
|
||||||
|
expect(ui).to receive(:info).with('Packaging domain...')
|
||||||
|
expect(ui).to receive(:info).with(/Downloading default_domain.img to .*\/box.img/)
|
||||||
|
expect(ui).to receive(:info).with('Image has backing image, copying image and rebasing ...')
|
||||||
|
expect(subject).to receive(:`).with(/qemu-img info .*\/box.img | grep 'backing file:' | cut -d ':' -f2/).and_return("some image")
|
||||||
|
expect(subject).to receive(:`).with(/qemu-img rebase -p -b "" .*\/box.img/)
|
||||||
|
expect(subject).to receive(:`).with(/virt-sysprep --no-logfile --operations .* -a .*\/box.img .*/)
|
||||||
|
expect(subject).to receive(:`).with(/virt-sparsify --in-place .*\/box.img/)
|
||||||
|
expect(subject).to receive(:`).with(/qemu-img info --output=json .*\/box.img/).and_return(
|
||||||
|
{ 'virtual-size': 5*1024*1024*1024 }.to_json
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(subject.call(env)).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#vagrantfile_content' do
|
describe '#vagrantfile_content' do
|
||||||
|
|||||||
Reference in New Issue
Block a user