Clean up specs
This commit is contained in:
parent
4a9d74514e
commit
227a598917
2 changed files with 25 additions and 23 deletions
|
@ -22,7 +22,9 @@ module Vagrant
|
|||
def create
|
||||
# FIXME: Ruby 1.8 users dont have SecureRandom
|
||||
machine_id = SecureRandom.hex(6)
|
||||
log, status = lxc :create, '--template', 'ubuntu-cloud', '--name', machine_id, '--', '-S', '/home/vagrant/.ssh/id_rsa.pub'
|
||||
public_key = Vagrant.source_root.join('../keys/vagrant.pub').expand_path.to_s
|
||||
log, status = lxc :create, '--template', 'ubuntu-cloud', '--name', machine_id, '--', '-S', public_key
|
||||
# TODO: Handle errors
|
||||
machine_id
|
||||
end
|
||||
|
||||
|
|
|
@ -30,45 +30,41 @@ describe Vagrant::LXC::Container do
|
|||
end
|
||||
|
||||
describe 'guard for container state' do
|
||||
let(:last_command) { @last_command }
|
||||
let(:machine_id) { 'random-machine-id' }
|
||||
let(:machine) { fire_double('Vagrant::Machine', id: machine_id) }
|
||||
|
||||
before do
|
||||
subject.stub(:lxc) do |*cmds|
|
||||
@last_command = cmds.join(' ')
|
||||
mock(exit_code: 0, stdout: '')
|
||||
end
|
||||
subject.stub :lxc
|
||||
subject.wait_until :running
|
||||
end
|
||||
|
||||
it 'runs lxc-wait with the machine id' do
|
||||
last_command.should include "--name #{machine_id}"
|
||||
end
|
||||
|
||||
it 'runs lxc-wait with upcased state' do
|
||||
last_command.should include "--state RUNNING"
|
||||
it 'runs lxc-wait with the machine id and upcased state' do
|
||||
subject.should have_received(:lxc).with(
|
||||
:wait,
|
||||
'--name', machine_id,
|
||||
'--state', 'RUNNING'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'creation' do
|
||||
let(:last_command) { @last_command }
|
||||
let(:new_machine_id) { 'random-machine-id' }
|
||||
let(:public_key_path) { Vagrant.source_root.join('..', 'keys', 'vagrant.pub').expand_path.to_s }
|
||||
|
||||
before do
|
||||
subject.stub(:lxc) do |*cmds|
|
||||
@last_command = cmds.join(' ')
|
||||
mock(exit_code: 0, stdout: '')
|
||||
end
|
||||
subject.stub(:lxc)
|
||||
SecureRandom.stub(hex: new_machine_id)
|
||||
subject.create
|
||||
end
|
||||
|
||||
it 'calls lxc-create with the right arguments' do
|
||||
last_command.should =~ /^create/
|
||||
last_command.should include "--name #{new_machine_id}"
|
||||
last_command.should include "--template ubuntu-cloud"
|
||||
last_command.should =~ /\-\- \-S (\w|\/|\.)+\/id_rsa\.pub$/
|
||||
subject.should have_received(:lxc).with(
|
||||
:create,
|
||||
'--template', 'ubuntu-cloud',
|
||||
'--name', new_machine_id,
|
||||
'--',
|
||||
'-S', public_key_path
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -82,7 +78,11 @@ describe Vagrant::LXC::Container do
|
|||
end
|
||||
|
||||
it 'calls lxc-start with the right arguments' do
|
||||
subject.should have_received(:lxc).with(:start, '-d', '--name', machine.id)
|
||||
subject.should have_received(:lxc).with(
|
||||
:start,
|
||||
'-d',
|
||||
'--name', machine.id
|
||||
)
|
||||
end
|
||||
|
||||
it 'waits for container state to be RUNNING' do
|
||||
|
|
Loading…
Reference in a new issue