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