lxc-wait: check

This commit is contained in:
Fabio Rehm 2013-03-01 23:07:15 -03:00
parent e9a5385c02
commit f1623a9136
2 changed files with 28 additions and 2 deletions

View file

@ -39,6 +39,10 @@ module Vagrant
File.delete(state_file_path) if state_file_path
end
def wait_until(state)
lxc :wait, '--name', @machine.id, '--state', state.to_s.upcase
end
def lxc(command, *args)
execute('sudo', "lxc-#{command}", *args)
end

View file

@ -23,13 +23,35 @@ describe Vagrant::LXC::Container do
args[1].should == 'lxc-command'
end
it 'sends remaining arguments for execution' do
it 'pass through remaining arguments' do
args[2].should == '--state'
args[3].should == 'RUNNING'
end
end
describe 'create' do
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.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"
end
end
describe 'creation' do
let(:last_command) { @last_command }
let(:new_machine_id) { 'random-machine-id' }