Only discard state if the VM is created
This commit is contained in:
parent
f7f36bbba4
commit
4335adc8f4
|
@ -9,7 +9,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
if env["vm"].vm.saved?
|
||||
if env["vm"].created? && env["vm"].vm.saved?
|
||||
env.ui.info "vagrant.actions.vm.discard_state.discarding"
|
||||
env["vm"].vm.discard_state
|
||||
end
|
||||
|
|
|
@ -16,11 +16,20 @@ class DiscardStateVMActionTest < Test::Unit::TestCase
|
|||
|
||||
context "calling" do
|
||||
setup do
|
||||
@vm.stubs(:created?).returns(true)
|
||||
@internal_vm.stubs(:saved?).returns(false)
|
||||
end
|
||||
|
||||
should "do nothing if the VM is not created" do
|
||||
@vm.stubs(:created?).returns(false)
|
||||
@internal_vm.expects(:discard_state).never
|
||||
@app.expects(:call).with(@env).once
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
||||
should "do nothing if not saved and continue chain" do
|
||||
@internal_vm.expects(:saved?).returns(false)
|
||||
@internal_vm.expects(:discard_state).never
|
||||
@app.expects(:call).with(@env).once
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue