vagrant-up and vagrant-halt no longer raise exceptions when the VM is not in the proper state.
This commit is contained in:
parent
c7f040f14c
commit
8e7621061f
|
@ -3,6 +3,8 @@ module Vagrant
|
|||
module VM
|
||||
class Halt < Base
|
||||
def execute!
|
||||
raise ActionException.new("VM is not running! Nothing to shut down!") unless @runner.vm.running?
|
||||
|
||||
logger.info "Forcing shutdown of VM..."
|
||||
@runner.vm.stop(true)
|
||||
end
|
||||
|
|
|
@ -26,6 +26,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
def start
|
||||
return if @vm.running?
|
||||
|
||||
actions = [Actions::VM::ForwardPorts, Actions::VM::SharedFolders, Actions::VM::Start]
|
||||
actions.each do |action|
|
||||
add_action(action)
|
||||
|
|
|
@ -7,9 +7,21 @@ class HaltActionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "executing" do
|
||||
setup do
|
||||
@vm.stubs(:running?).returns(true)
|
||||
end
|
||||
|
||||
should "force the VM to stop" do
|
||||
@vm.expects(:stop).with(true).once
|
||||
@action.execute!
|
||||
end
|
||||
|
||||
should "raise an ActionException if VM is not running" do
|
||||
@vm.stubs(:running?).returns(false)
|
||||
@vm.expects(:stop).never
|
||||
assert_raises(Vagrant::Actions::ActionException) {
|
||||
@action.execute!
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,6 +80,16 @@ class VMTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "starting" do
|
||||
setup do
|
||||
@mock_vm.stubs(:running?).returns(false)
|
||||
end
|
||||
|
||||
should "not do anything if the VM is already running" do
|
||||
@mock_vm.stubs(:running?).returns(true)
|
||||
@vm.expects(:execute!).never
|
||||
@vm.start
|
||||
end
|
||||
|
||||
should "add and execute the proper actions" do
|
||||
actions = [Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Start]
|
||||
|
||||
|
|
Loading…
Reference in New Issue