Clean up the mess I left behind

This commit is contained in:
Fabio Rehm 2013-06-08 02:01:50 -03:00
parent a5eb824fa4
commit 51d26b00cd
4 changed files with 15 additions and 5 deletions

View file

@ -50,7 +50,7 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do
metadata['version'] = '1' metadata['version'] = '1'
expect { expect {
subject.call(env) subject.call(env)
}.to raise_error(Vagrant::LXC::Errors::InvalidBoxVersion) }.to raise_error(Vagrant::LXC::Errors::IncompatibleBox)
end end
it 'raises an error if the rootfs tarball cant be found' do it 'raises an error if the rootfs tarball cant be found' do

View file

@ -14,7 +14,8 @@ describe Vagrant::LXC::Action::SetupPackageFiles do
before do before do
box.directory.mkdir box.directory.mkdir
[box.directory.join('lxc-template'), box.directory.join('metadata.json'), rootfs_path].each do |file| files = %w( lxc-template metadata.json lxc.conf ).map { |f| box.directory.join(f) }
(files + [rootfs_path]).each do |file|
file.open('w') { |f| f.puts file.to_s } file.open('w') { |f| f.puts file.to_s }
end end
@ -34,6 +35,10 @@ describe Vagrant::LXC::Action::SetupPackageFiles do
env['package.directory'].join('metadata.json').should be_file env['package.directory'].join('metadata.json').should be_file
end 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 it 'moves the compressed rootfs to package directory' do
env['package.directory'].join(rootfs_path.basename).should be_file env['package.directory'].join(rootfs_path.basename).should be_file
env['package.rootfs'].should_not be_file env['package.rootfs'].should_not be_file

View file

@ -38,13 +38,14 @@ describe Vagrant::LXC::Driver::CLI do
describe 'create' do describe 'create' do
let(:template) { 'quantal-64' } let(:template) { 'quantal-64' }
let(:name) { 'quantal-container' } let(:name) { 'quantal-container' }
let(:config_file) { 'config' }
let(:template_args) { { '--extra-param' => 'param', '--other' => 'value' } } let(:template_args) { { '--extra-param' => 'param', '--other' => 'value' } }
subject { described_class.new(name) } subject { described_class.new(name) }
before do before do
subject.stub(:run) { |*args| @run_args = args } subject.stub(:run) { |*args| @run_args = args }
subject.create(template, template_args) subject.create(template, config_file, template_args)
end end
it 'issues a lxc-create with provided template, container name and hash of arguments' do it 'issues a lxc-create with provided template, container name and hash of arguments' do
@ -52,6 +53,7 @@ describe Vagrant::LXC::Driver::CLI do
:create, :create,
'--template', template, '--template', template,
'--name', name, '--name', name,
'-f', config_file,
'--', '--',
'--extra-param', 'param', '--extra-param', 'param',
'--other', 'value' '--other', 'value'

View file

@ -35,6 +35,7 @@ describe Vagrant::LXC::Driver do
let(:template_name) { 'auto-assigned-template-id' } let(:template_name) { 'auto-assigned-template-id' }
let(:template_path) { '/path/to/lxc-template-from-box' } let(:template_path) { '/path/to/lxc-template-from-box' }
let(:template_opts) { {'--some' => 'random-option'} } let(:template_opts) { {'--some' => 'random-option'} }
let(:config_file) { '/path/to/lxc-config-from-box' }
let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' } let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' }
let(:cli) { fire_double('Vagrant::LXC::Driver::CLI', :create => true, :name= => true) } let(:cli) { fire_double('Vagrant::LXC::Driver::CLI', :create => true, :name= => true) }
@ -42,7 +43,7 @@ describe Vagrant::LXC::Driver do
before do before do
subject.stub(:import_template).and_yield(template_name) subject.stub(:import_template).and_yield(template_name)
subject.create name, template_path, template_opts subject.create name, template_path, config_file, template_opts
end end
it 'sets the cli object container name' do it 'sets the cli object container name' do
@ -52,6 +53,7 @@ describe Vagrant::LXC::Driver do
it 'creates container with the right arguments' do it 'creates container with the right arguments' do
cli.should have_received(:create).with( cli.should have_received(:create).with(
template_name, template_name,
config_file,
template_opts template_opts
) )
end end
@ -72,6 +74,7 @@ describe Vagrant::LXC::Driver do
describe 'start' do describe 'start' do
let(:customizations) { [['a', '1'], ['b', '2']] } let(:customizations) { [['a', '1'], ['b', '2']] }
let(:internal_customization) { ['internal', 'customization'] } let(:internal_customization) { ['internal', 'customization'] }
let(:rootfs) { ['rootfs', subject.rootfs_path.to_s] }
let(:cli) { fire_double('Vagrant::LXC::Driver::CLI', start: true) } let(:cli) { fire_double('Vagrant::LXC::Driver::CLI', start: true) }
subject { described_class.new('name', cli) } subject { described_class.new('name', cli) }
@ -83,7 +86,7 @@ describe Vagrant::LXC::Driver do
end end
it 'starts container with configured customizations' do it 'starts container with configured customizations' do
cli.should have_received(:start).with(customizations + [internal_customization], nil) cli.should have_received(:start).with(customizations + [internal_customization, rootfs], nil)
end end
it 'expects a transition to running state to take place' do it 'expects a transition to running state to take place' do