Only halt if created and running
This commit is contained in:
parent
4335adc8f4
commit
e11d3bd4f7
|
@ -8,7 +8,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
if env["vm"].vm.running?
|
||||
if env["vm"].created? && env["vm"].vm.running?
|
||||
env["vm"].system.halt if !env["force"]
|
||||
|
||||
if env["vm"].vm.state(true) != :powered_off
|
||||
|
|
|
@ -26,6 +26,7 @@ class HaltVMActionTest < Test::Unit::TestCase
|
|||
|
||||
context "calling" do
|
||||
setup do
|
||||
@vm.stubs(:created?).returns(true)
|
||||
@internal_vm.stubs(:running?).returns(true)
|
||||
|
||||
@vm.system.stubs(:halt)
|
||||
|
@ -33,6 +34,15 @@ class HaltVMActionTest < Test::Unit::TestCase
|
|||
@internal_vm.stubs(:state).returns(:powered_off)
|
||||
end
|
||||
|
||||
should "do nothing if VM is not created" do
|
||||
@internal_vm.stubs(:created?).returns(false)
|
||||
@vm.system.expects(:halt).never
|
||||
@internal_vm.expects(:stop).never
|
||||
@app.expects(:call).once
|
||||
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
||||
should "do nothing if VM not running" do
|
||||
@internal_vm.stubs(:running?).returns(false)
|
||||
@vm.system.expects(:halt).never
|
||||
|
|
Loading…
Reference in New Issue