Provision command checks if VM is created

This commit is contained in:
Mitchell Hashimoto 2010-06-14 13:09:32 -07:00
parent f4ab30238a
commit b84123dcd9
2 changed files with 11 additions and 1 deletions

View File

@ -16,7 +16,7 @@ module Vagrant
return # for tests
end
if vm.vm.running?
if vm.created? && vm.vm.running?
vm.provision
else
vm.env.logger.info "VM '#{name}' not running. Ignoring provision request."

View File

@ -18,6 +18,7 @@ class CommandsProvisionTest < Test::Unit::TestCase
setup do
@foo_vm = mock("vm")
@foo_vm.stubs(:env).returns(@env)
@foo_vm.stubs(:created?).returns(true)
@vm_for_real = mock("vm for real")
@foo_vm.stubs(:vm).returns(@vm_for_real)
@ -45,6 +46,15 @@ class CommandsProvisionTest < Test::Unit::TestCase
@foo_vm.expects(:provision).never
@instance.execute(["foo"])
end
should "do log to info if it's not created" do
logger = mock("logger")
logger.expects(:info)
@env.stubs(:logger).returns(logger)
@foo_vm.stubs(:created?).returns(false)
@foo_vm.expects(:provision).never
@instance.execute(["foo"])
end
end
end