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
describe 'create' do
let(:template) { 'quantal-64' }
let(:name) { 'quantal-container' }
let(:config_file) { 'config' }
let(:template_args) { { '--extra-param' => 'param', '--other' => 'value' } }
let(:template) { 'quantal-64' }
let(:name) { 'quantal-container' }
let(:backingstore) { 'btrfs' }
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) }
@ -53,9 +55,11 @@ describe Vagrant::LXC::Driver::CLI do
end
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(
:create,
'-B', backingstore,
*(backingstore_opts.flatten),
'--template', template,
'--name', name,
'-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
allow(subject).to receive(:run) { raise Vagrant::LXC::Errors::ExecuteError, stderr: 'alreAdy Exists' }
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)
end
end

View file

@ -31,19 +31,21 @@ describe Vagrant::LXC::Driver do
end
describe 'creation' do
let(:name) { 'container-name' }
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) { double(Vagrant::LXC::Driver::CLI, :create => true, :name= => true) }
let(:name) { 'container-name' }
let(:backingstore) { 'btrfs' }
let(:backingstore_opts) { [['--dir', '/tmp/foo'], ['--foo', 'bar']] }
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) { double(Vagrant::LXC::Driver::CLI, :create => true, :name= => true) }
subject { described_class.new(nil, nil, cli) }
before do
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
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
expect(cli).to have_received(:create).with(
template_name,
backingstore,
backingstore_opts,
config_file,
template_opts
)