From 51d26b00cd1daf005ce02e457ce0219704a36756 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 8 Jun 2013 02:01:50 -0300 Subject: [PATCH] Clean up the mess I left behind --- spec/unit/action/handle_box_metadata_spec.rb | 2 +- spec/unit/action/setup_package_files_spec.rb | 7 ++++++- spec/unit/driver/cli_spec.rb | 4 +++- spec/unit/driver_spec.rb | 7 +++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/spec/unit/action/handle_box_metadata_spec.rb b/spec/unit/action/handle_box_metadata_spec.rb index 2d3df93..578fbf9 100644 --- a/spec/unit/action/handle_box_metadata_spec.rb +++ b/spec/unit/action/handle_box_metadata_spec.rb @@ -50,7 +50,7 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do metadata['version'] = '1' expect { subject.call(env) - }.to raise_error(Vagrant::LXC::Errors::InvalidBoxVersion) + }.to raise_error(Vagrant::LXC::Errors::IncompatibleBox) end it 'raises an error if the rootfs tarball cant be found' do diff --git a/spec/unit/action/setup_package_files_spec.rb b/spec/unit/action/setup_package_files_spec.rb index 4e50189..68d3133 100644 --- a/spec/unit/action/setup_package_files_spec.rb +++ b/spec/unit/action/setup_package_files_spec.rb @@ -14,7 +14,8 @@ describe Vagrant::LXC::Action::SetupPackageFiles do before do 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 } end @@ -34,6 +35,10 @@ describe Vagrant::LXC::Action::SetupPackageFiles 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 diff --git a/spec/unit/driver/cli_spec.rb b/spec/unit/driver/cli_spec.rb index 9394459..3498b6a 100644 --- a/spec/unit/driver/cli_spec.rb +++ b/spec/unit/driver/cli_spec.rb @@ -38,13 +38,14 @@ describe Vagrant::LXC::Driver::CLI do describe 'create' do let(:template) { 'quantal-64' } let(:name) { 'quantal-container' } + let(:config_file) { 'config' } let(:template_args) { { '--extra-param' => 'param', '--other' => 'value' } } subject { described_class.new(name) } before do subject.stub(:run) { |*args| @run_args = args } - subject.create(template, template_args) + subject.create(template, config_file, template_args) end 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, '--template', template, '--name', name, + '-f', config_file, '--', '--extra-param', 'param', '--other', 'value' diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 1b0833d..f657648 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -35,6 +35,7 @@ describe Vagrant::LXC::Driver do let(:template_name) { 'auto-assigned-template-id' } let(:template_path) { '/path/to/lxc-template-from-box' } 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(:cli) { fire_double('Vagrant::LXC::Driver::CLI', :create => true, :name= => true) } @@ -42,7 +43,7 @@ describe Vagrant::LXC::Driver do before do 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 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 cli.should have_received(:create).with( template_name, + config_file, template_opts ) end @@ -72,6 +74,7 @@ describe Vagrant::LXC::Driver do describe 'start' do let(:customizations) { [['a', '1'], ['b', '2']] } let(:internal_customization) { ['internal', 'customization'] } + let(:rootfs) { ['rootfs', subject.rootfs_path.to_s] } let(:cli) { fire_double('Vagrant::LXC::Driver::CLI', start: true) } subject { described_class.new('name', cli) } @@ -83,7 +86,7 @@ describe Vagrant::LXC::Driver do end 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 it 'expects a transition to running state to take place' do