From bf0aff45f69f7a32490227f93a1d6060767795c8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 14 Feb 2010 23:58:02 -0800 Subject: [PATCH] Move hard drive action added to Up if config is set --- lib/vagrant/actions/up.rb | 7 ++++--- test/vagrant/actions/up_test.rb | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/actions/up.rb b/lib/vagrant/actions/up.rb index 004d29391..1ee980caa 100644 --- a/lib/vagrant/actions/up.rb +++ b/lib/vagrant/actions/up.rb @@ -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 diff --git a/test/vagrant/actions/up_test.rb b/test/vagrant/actions/up_test.rb index 8c4c0d715..bc6a71a8d 100644 --- a/test/vagrant/actions/up_test.rb +++ b/test/vagrant/actions/up_test.rb @@ -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")