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