Port collision detection ignores if the VM is the current VM
This commit is contained in:
parent
de54433496
commit
51116438a7
|
@ -4,7 +4,7 @@ module Vagrant
|
|||
class ForwardPorts < Base
|
||||
def prepare
|
||||
VirtualBox::VM.all.each do |vm|
|
||||
next unless vm.running?
|
||||
next if !vm.running? || vm.uuid == @runner.uuid
|
||||
|
||||
vm.forwarded_ports.each do |fp|
|
||||
Vagrant.config.vm.forwarded_ports.each do |name, options|
|
||||
|
|
|
@ -20,7 +20,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def uuid
|
||||
@vm.uuid
|
||||
vm ? vm.uuid : nil
|
||||
end
|
||||
|
||||
def reload!
|
||||
|
|
|
@ -15,6 +15,8 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|||
@vm = mock("vm")
|
||||
@vm.stubs(:forwarded_ports).returns(@forwarded_ports)
|
||||
@vm.stubs(:running?).returns(true)
|
||||
@vm.stubs(:uuid).returns("foo")
|
||||
@mock_vm.stubs(:uuid).returns("bar")
|
||||
vms = [@vm]
|
||||
VirtualBox::VM.stubs(:all).returns(vms)
|
||||
|
||||
|
@ -30,6 +32,12 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|||
@action.prepare
|
||||
end
|
||||
|
||||
should "ignore vms which are equivalent to ours" do
|
||||
@mock_vm.expects(:uuid).returns(@vm.uuid)
|
||||
@vm.expects(:forwarded_ports).never
|
||||
@action.prepare
|
||||
end
|
||||
|
||||
should "not raise any errors if no forwarded ports collide" do
|
||||
@forwarded_port.expects(:hostport).returns(80)
|
||||
assert_nothing_raised { @action.prepare }
|
||||
|
|
|
@ -44,6 +44,11 @@ class VMTest < Test::Unit::TestCase
|
|||
@mock_vm.expects(:uuid).once.returns(uuid)
|
||||
assert_equal uuid, @vm.uuid
|
||||
end
|
||||
|
||||
should "return nil if vm is nil" do
|
||||
@vm.expects(:vm).returns(nil)
|
||||
assert @vm.uuid.nil?
|
||||
end
|
||||
end
|
||||
|
||||
context "reloading" do
|
||||
|
|
Loading…
Reference in New Issue