Fix broken specs

This commit is contained in:
Fabio Rehm 2014-05-04 20:50:04 -03:00
parent 856a847bc8
commit b17fb7baa8
2 changed files with 22 additions and 14 deletions

View file

@ -41,10 +41,12 @@ describe Vagrant::LXC::Driver::CLI do
end end
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(:backingstore) { 'btrfs' }
let(:template_args) { { '--extra-param' => 'param', '--other' => 'value' } } let(:backingstore_opts) { [['--dir', '/tmp/foo'], ['--foo', 'bar']] }
let(:config_file) { 'config' }
let(:template_args) { { '--extra-param' => 'param', '--other' => 'value' } }
subject { described_class.new(sudo_wrapper, name) } subject { described_class.new(sudo_wrapper, name) }
@ -53,9 +55,11 @@ describe Vagrant::LXC::Driver::CLI do
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
subject.create(template, config_file, template_args) subject.create(template, backingstore, backingstore_opts, config_file, template_args)
expect(subject).to have_received(:run).with( expect(subject).to have_received(:run).with(
:create, :create,
'-B', backingstore,
*(backingstore_opts.flatten),
'--template', template, '--template', template,
'--name', name, '--name', name,
'-f', config_file, '-f', config_file,
@ -68,7 +72,7 @@ describe Vagrant::LXC::Driver::CLI do
it 'wraps a low level error into something more meaningful in case the container already exists' do it 'wraps a low level error into something more meaningful in case the container already exists' do
allow(subject).to receive(:run) { raise Vagrant::LXC::Errors::ExecuteError, stderr: 'alreAdy Exists' } allow(subject).to receive(:run) { raise Vagrant::LXC::Errors::ExecuteError, stderr: 'alreAdy Exists' }
expect { expect {
subject.create(template, config_file, template_args) subject.create(template, backingstore, backingstore_opts, config_file, template_args)
}.to raise_error(Vagrant::LXC::Errors::ContainerAlreadyExists) }.to raise_error(Vagrant::LXC::Errors::ContainerAlreadyExists)
end end
end end

View file

@ -31,19 +31,21 @@ describe Vagrant::LXC::Driver do
end end
describe 'creation' do describe 'creation' do
let(:name) { 'container-name' } let(:name) { 'container-name' }
let(:template_name) { 'auto-assigned-template-id' } let(:backingstore) { 'btrfs' }
let(:template_path) { '/path/to/lxc-template-from-box' } let(:backingstore_opts) { [['--dir', '/tmp/foo'], ['--foo', 'bar']] }
let(:template_opts) { {'--some' => 'random-option'} } let(:template_name) { 'auto-assigned-template-id' }
let(:config_file) { '/path/to/lxc-config-from-box' } let(:template_path) { '/path/to/lxc-template-from-box' }
let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' } let(:template_opts) { {'--some' => 'random-option'} }
let(:cli) { double(Vagrant::LXC::Driver::CLI, :create => true, :name= => true) } let(:config_file) { '/path/to/lxc-config-from-box' }
let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' }
let(:cli) { double(Vagrant::LXC::Driver::CLI, :create => true, :name= => true) }
subject { described_class.new(nil, nil, cli) } subject { described_class.new(nil, nil, cli) }
before do before do
allow(subject).to receive(:import_template).and_yield(template_name) allow(subject).to receive(:import_template).and_yield(template_name)
subject.create name, template_path, config_file, template_opts subject.create name, backingstore, backingstore_opts, template_path, config_file, template_opts
end end
it 'sets the cli object container name' do it 'sets the cli object container name' do
@ -53,6 +55,8 @@ describe Vagrant::LXC::Driver do
it 'creates container with the right arguments' do it 'creates container with the right arguments' do
expect(cli).to have_received(:create).with( expect(cli).to have_received(:create).with(
template_name, template_name,
backingstore,
backingstore_opts,
config_file, config_file,
template_opts template_opts
) )