Test coverage for 'check for redir'
Includes a minor refactor allowing variation of the result of the system call per test
This commit is contained in:
parent
17211387d0
commit
eb0854b6fb
1 changed files with 9 additions and 2 deletions
|
@ -23,20 +23,27 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
||||||
|
|
||||||
subject.stub(exec: true)
|
subject.stub(exec: true)
|
||||||
subject.stub(spawn: pid)
|
subject.stub(spawn: pid)
|
||||||
subject.stub(system: true)
|
|
||||||
subject.call(env)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after { FileUtils.rm_rf data_dir.to_s }
|
after { FileUtils.rm_rf data_dir.to_s }
|
||||||
|
|
||||||
it 'forwards ports using redir' do
|
it 'forwards ports using redir' do
|
||||||
|
subject.stub(system: true)
|
||||||
|
subject.call(env)
|
||||||
subject.should have_received(:spawn).with(
|
subject.should have_received(:spawn).with(
|
||||||
"sudo redir --laddr=127.0.0.1 --lport=#{host_port} --cport=#{guest_port} --caddr=#{container_ip} 2>/dev/null"
|
"sudo redir --laddr=127.0.0.1 --lport=#{host_port} --cport=#{guest_port} --caddr=#{container_ip} 2>/dev/null"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "stores redir pids on machine's data dir" do
|
it "stores redir pids on machine's data dir" do
|
||||||
|
subject.stub(system: true)
|
||||||
|
subject.call(env)
|
||||||
pid_file = data_dir.join('pids', "redir_#{host_port}.pid").read
|
pid_file = data_dir.join('pids', "redir_#{host_port}.pid").read
|
||||||
pid_file.should == pid
|
pid_file.should == pid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'raises RedirNotInstalled error if `redir` is not installed' do
|
||||||
|
subject.stub(system: false)
|
||||||
|
lambda { subject.call(env) }.should raise_error(Vagrant::LXC::Errors::RedirNotInstalled)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue