Move hard drive action added to Up if config is set

This commit is contained in:
Mitchell Hashimoto 2010-02-14 23:58:02 -08:00
parent 6a79c4268b
commit bf0aff45f6
2 changed files with 34 additions and 4 deletions

View File

@ -4,11 +4,12 @@ module Vagrant
def prepare
# Up is a "meta-action" so it really just queues up a bunch
# of other actions in its place:
[Import, ForwardPorts, SharedFolders, Start].each do |action_klass|
steps = [Import, ForwardPorts, SharedFolders, Start]
steps.insert(1, MoveHardDrive) if Vagrant.config.vm.hd_location
steps.each do |action_klass|
@vm.add_action(action_klass)
end
# TODO: Move hard drive
end
def collect_shared_folders

View File

@ -2,10 +2,39 @@ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
class UpActionTest < Test::Unit::TestCase
setup do
@mock_vm, @vm, @import = mock_action(Vagrant::Actions::Up)
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::Up)
mock_config
end
context "sub-actions" do
setup do
@default_order = [Vagrant::Actions::Import, Vagrant::Actions::ForwardPorts, Vagrant::Actions::SharedFolders, Vagrant::Actions::Start]
end
def setup_action_expectations
default_seq = sequence("default_seq")
@default_order.each do |action|
@mock_vm.expects(:add_action).with(action).once.in_sequence(default_seq)
end
end
should "do the proper actions by default" do
setup_action_expectations
@action.prepare
end
should "add in the action to move hard drive if config is set" do
mock_config do |config|
File.expects(:directory?).with("foo").returns(true)
config.vm.hd_location = "foo"
end
@default_order.insert(1, Vagrant::Actions::MoveHardDrive)
setup_action_expectations
@action.prepare
end
end
context "callbacks" do
should "call persist and mac address setup after import" do
boot_seq = sequence("boot")