Only discard state if the VM is created

This commit is contained in:
Mitchell Hashimoto 2010-09-12 16:26:32 -06:00
parent f7f36bbba4
commit 4335adc8f4
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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