Refactor up/start actions.
This commit is contained in:
parent
3774bc4f59
commit
661af82e63
|
@ -6,7 +6,10 @@ module Vagrant
|
||||||
# Start is a "meta-action" so it really just queues up a bunch
|
# Start is a "meta-action" so it really just queues up a bunch
|
||||||
# of other actions in its place:
|
# of other actions in its place:
|
||||||
steps = [Boot]
|
steps = [Boot]
|
||||||
steps.unshift([Customize, ForwardPorts, SharedFolders]) unless @runner.vm.saved?
|
if !@runner.vm || !@runner.vm.saved?
|
||||||
|
steps.unshift([Customize, ForwardPorts, SharedFolders])
|
||||||
|
steps << Provision if !@runner.env.config.vm.provisioner.nil?
|
||||||
|
end
|
||||||
|
|
||||||
steps.flatten.each do |action_klass|
|
steps.flatten.each do |action_klass|
|
||||||
@runner.add_action(action_klass)
|
@runner.add_action(action_klass)
|
||||||
|
|
|
@ -10,8 +10,7 @@ module Vagrant
|
||||||
|
|
||||||
# Up is a "meta-action" so it really just queues up a bunch
|
# Up is a "meta-action" so it really just queues up a bunch
|
||||||
# of other actions in its place:
|
# of other actions in its place:
|
||||||
steps = [Import, Customize, ForwardPorts, SharedFolders, Boot]
|
steps = [Import, Start]
|
||||||
steps << Provision if !@runner.env.config.vm.provisioner.nil?
|
|
||||||
steps.insert(0, MoveHardDrive) if @runner.env.config.vm.hd_location
|
steps.insert(0, MoveHardDrive) if @runner.env.config.vm.hd_location
|
||||||
|
|
||||||
steps.each do |action_klass|
|
steps.each do |action_klass|
|
||||||
|
|
|
@ -31,5 +31,22 @@ class StartActionTest < Test::Unit::TestCase
|
||||||
setup_action_expectations
|
setup_action_expectations
|
||||||
@action.prepare
|
@action.prepare
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "add do additional if VM is not created yet" do
|
||||||
|
@mock_vm.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
|
||||||
|
|
||||||
|
should "add provisioning if its enabled and not saved" do
|
||||||
|
@vm.env.config.vm.provisioner = :chef_solo
|
||||||
|
|
||||||
|
@mock_vm.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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class UpActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
File.stubs(:file?).returns(true)
|
File.stubs(:file?).returns(true)
|
||||||
File.stubs(:exist?).returns(true)
|
File.stubs(:exist?).returns(true)
|
||||||
@default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Boot]
|
@default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Start]
|
||||||
|
|
||||||
@dotfile_path = "foo"
|
@dotfile_path = "foo"
|
||||||
@runner.env.stubs(:dotfile_path).returns(@dotfile_path)
|
@runner.env.stubs(:dotfile_path).returns(@dotfile_path)
|
||||||
|
@ -47,19 +47,6 @@ class UpActionTest < Test::Unit::TestCase
|
||||||
@action.prepare
|
@action.prepare
|
||||||
end
|
end
|
||||||
|
|
||||||
should "add in the provisioning step if enabled" do
|
|
||||||
env = mock_environment do |config|
|
|
||||||
config.vm.provisioner = "foo"
|
|
||||||
end
|
|
||||||
|
|
||||||
@runner.stubs(:env).returns(env)
|
|
||||||
env.stubs(:dotfile_path).returns(@dotfile_path)
|
|
||||||
|
|
||||||
@default_order.push(Vagrant::Actions::VM::Provision)
|
|
||||||
setup_action_expectations
|
|
||||||
@action.prepare
|
|
||||||
end
|
|
||||||
|
|
||||||
should "add in the action to move hard drive if config is set" do
|
should "add in the action to move hard drive if config is set" do
|
||||||
env = mock_environment do |config|
|
env = mock_environment do |config|
|
||||||
File.expects(:directory?).with("foo").returns(true)
|
File.expects(:directory?).with("foo").returns(true)
|
||||||
|
|
Loading…
Reference in New Issue