Only destroy the VM if the exception raised is not a Vagrant error
This commit is contained in:
parent
7c42300002
commit
036edfcc2a
|
@ -23,6 +23,8 @@ module Vagrant
|
||||||
|
|
||||||
def recover(env)
|
def recover(env)
|
||||||
if env["vm"].created?
|
if env["vm"].created?
|
||||||
|
return if env["vagrant.error"].is_a?(Errors::VagrantError)
|
||||||
|
|
||||||
# Interrupted, destroy the VM
|
# Interrupted, destroy the VM
|
||||||
env["actions"].run(:destroy)
|
env["actions"].run(:destroy)
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,15 +40,27 @@ class ImportVMActionTest < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not run the destroy action on recover if VM is not created" do
|
context "recovery" do
|
||||||
@env.env.vm.stubs(:created?).returns(false)
|
setup do
|
||||||
@env.env.actions.expects(:run).never
|
@env.env.vm.stubs(:created?).returns(true)
|
||||||
@instance.recover(@env)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
should "run the destroy action on recover" do
|
should "not run the destroy action on recover if error is a VagrantError" do
|
||||||
@env.env.vm.stubs(:created?).returns(true)
|
@env["vagrant.error"] = Vagrant::Errors::VMImportFailure.new
|
||||||
@env.env.actions.expects(:run).with(:destroy).once
|
@env.env.actions.expects(:run).never
|
||||||
@instance.recover(@env)
|
@instance.recover(@env)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not run the destroy action on recover if VM is not created" do
|
||||||
|
@env.env.vm.stubs(:created?).returns(false)
|
||||||
|
@env.env.actions.expects(:run).never
|
||||||
|
@instance.recover(@env)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "run the destroy action on recover" do
|
||||||
|
@env.env.vm.stubs(:created?).returns(true)
|
||||||
|
@env.env.actions.expects(:run).with(:destroy).once
|
||||||
|
@instance.recover(@env)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue