Prevent vagrant package from blowing up

This commit is contained in:
Fabio Rehm 2013-06-08 02:07:56 -03:00
parent 51d26b00cd
commit 8512c5ace7
2 changed files with 29 additions and 14 deletions

View file

@ -45,7 +45,9 @@ module Vagrant
box_dir = @env[:machine].box.directory
FileUtils.cp box_dir.join('lxc-template').to_s, @env['package.directory'].to_s
FileUtils.cp box_dir.join('metadata.json').to_s, @env['package.directory'].to_s
FileUtils.cp box_dir.join('lxc.conf').to_s, @env['package.directory'].to_s
if (conf = box_dir.join('lxc.conf')).exist?
FileUtils.cp conf.to_s, @env['package.directory'].to_s
end
end
end
end

View file

@ -20,27 +20,40 @@ describe Vagrant::LXC::Action::SetupPackageFiles do
end
subject.stub(recover: true) # Prevents files from being removed on specs
subject.call(env)
end
after do
FileUtils.rm_rf(tmp_path.to_s)
end
it 'copies box lxc-template to package directory' do
env['package.directory'].join('lxc-template').should be_file
context 'when all files exist' do
before { subject.call(env) }
it 'copies box lxc-template to package directory' do
env['package.directory'].join('lxc-template').should be_file
end
it 'copies metadata.json to package directory' do
env['package.directory'].join('metadata.json').should be_file
end
it 'copies box lxc.conf to package directory' do
env['package.directory'].join('lxc-template').should be_file
end
it 'moves the compressed rootfs to package directory' do
env['package.directory'].join(rootfs_path.basename).should be_file
env['package.rootfs'].should_not be_file
end
end
it 'copies metadata.json to package directory' do
env['package.directory'].join('metadata.json').should be_file
end
context 'when lxc.conf file is not present' do
before do
box.directory.join('lxc.conf').delete
end
it 'copies box lxc.conf to package directory' do
env['package.directory'].join('lxc-template').should be_file
end
it 'moves the compressed rootfs to package directory' do
env['package.directory'].join(rootfs_path.basename).should be_file
env['package.rootfs'].should_not be_file
it 'does not blow up' do
expect { subject.call(env) }.to_not raise_error
end
end
end