Do not reload VM and everything if no forwarded ports were destroyed

This commit is contained in:
Mitchell Hashimoto 2010-06-03 20:34:02 -07:00
parent b00442026f
commit 97facb08fd
2 changed files with 13 additions and 5 deletions

View File

@ -67,10 +67,12 @@ module Vagrant
end
def clear
logger.info "Deleting any previously set forwarded ports..."
fp = @runner.vm.forwarded_ports.dup
fp.collect { |p| p.destroy }
@runner.reload!
if runner.vm.forwarded_ports.length > 0
logger.info "Deleting any previously set forwarded ports..."
fp = runner.vm.forwarded_ports.dup
fp.collect { |p| p.destroy }
runner.reload!
end
end
def forward_ports

View File

@ -164,9 +164,15 @@ class ForwardPortsActionTest < Test::Unit::TestCase
forwarded_ports << port
end
@vm.expects(:forwarded_ports).returns(forwarded_ports)
@vm.stubs(:forwarded_ports).returns(forwarded_ports)
@runner.expects(:reload!)
@action.clear
end
should "do nothing if there are no forwarded ports" do
@vm.stubs(:forwarded_ports).returns([])
@runner.expects(:reload!).never
@action.clear
end
end
end