On import, only run destroy action if VM is created
This commit is contained in:
parent
7d73bec776
commit
714c94780c
|
@ -22,8 +22,10 @@ module Vagrant
|
|||
end
|
||||
|
||||
def recover(env)
|
||||
# Interrupted, destroy the VM
|
||||
env["actions"].run(:destroy)
|
||||
if env["vm"].created?
|
||||
# Interrupted, destroy the VM
|
||||
env["actions"].run(:destroy)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,11 +40,15 @@ class ImportVMActionTest < Test::Unit::TestCase
|
|||
}
|
||||
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 = mock("env")
|
||||
destroy = mock("destory")
|
||||
env.expects(:[]).with("actions").returns(destroy)
|
||||
destroy.expects(:run).with(:destroy)
|
||||
@instance.recover(env)
|
||||
@env.env.vm.stubs(:created?).returns(true)
|
||||
@env.env.actions.expects(:run).with(:destroy).once
|
||||
@instance.recover(@env)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue