Changed semantics of 'up.' 'up' will now only provision when the VM is being created from scratch. Otherwise, it simply starts the VM. [closes GH-78]

This commit is contained in:
Mitchell Hashimoto 2010-05-22 18:54:33 -07:00
parent d76e9ba26a
commit b949861186
3 changed files with 18 additions and 5 deletions

View File

@ -8,7 +8,7 @@ module Vagrant
steps = [Boot]
if !@runner.vm || !@runner.vm.saved?
steps.unshift([Customize, ForwardPorts, SharedFolders])
steps << Provision if !@runner.env.config.vm.provisioner.nil?
steps << Provision if !@runner.env.config.vm.provisioner.nil? && !@runner.created?
end
steps.flatten.each do |action_klass|

View File

@ -2,11 +2,12 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
class StartActionTest < Test::Unit::TestCase
setup do
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Start)
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Start)
end
context "sub-actions" do
setup do
@runner.stubs(:created?).returns(false)
@vm.stubs(:saved?).returns(true)
File.stubs(:file?).returns(true)
File.stubs(:exist?).returns(true)
@ -16,7 +17,7 @@ class StartActionTest < Test::Unit::TestCase
def setup_action_expectations
default_seq = sequence("default_seq")
@default_order.flatten.each do |action|
@mock_vm.expects(:add_action).with(action).once.in_sequence(default_seq)
@runner.expects(:add_action).with(action).once.in_sequence(default_seq)
end
end
@ -33,7 +34,7 @@ class StartActionTest < Test::Unit::TestCase
end
should "add do additional if VM is not created yet" do
@mock_vm.stubs(:vm).returns(nil)
@runner.stubs(:vm).returns(nil)
@default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders])
setup_action_expectations
@action.prepare
@ -42,11 +43,21 @@ class StartActionTest < Test::Unit::TestCase
should "add provisioning if its enabled and not saved" do
@vm.env.config.vm.provisioner = :chef_solo
@mock_vm.stubs(:vm).returns(nil)
@runner.stubs(:vm).returns(nil)
@default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders])
@default_order << Vagrant::Actions::VM::Provision
setup_action_expectations
@action.prepare
end
should "not add provisioning if enabled but already created" do
@runner.stubs(:created?).returns(true)
@vm.env.config.vm.provisioner = :chef_solo
@runner.stubs(:vm).returns(nil)
@default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders])
setup_action_expectations
@action.prepare
end
end
end

View File

@ -7,6 +7,8 @@ class UpActionTest < Test::Unit::TestCase
context "sub-actions" do
setup do
@runner.stubs(:created?).returns(false)
File.stubs(:file?).returns(true)
File.stubs(:exist?).returns(true)
@default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Start]