From 4e54cc77a23dcc015513a5b685e3b3e337087495 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Apr 2010 23:28:53 -0700 Subject: [PATCH] Remove old test mocks from the pre-instanced environment days --- test/test_helper.rb | 55 ------------------- test/vagrant/actions/box/add_test.rb | 1 - test/vagrant/actions/box/destroy_test.rb | 1 - test/vagrant/actions/box/download_test.rb | 1 - test/vagrant/actions/box/unpackage_test.rb | 1 - test/vagrant/actions/vm/boot_test.rb | 1 - test/vagrant/actions/vm/customize_test.rb | 1 - test/vagrant/actions/vm/down_test.rb | 1 - test/vagrant/actions/vm/export_test.rb | 1 - test/vagrant/actions/vm/forward_ports_test.rb | 1 - test/vagrant/actions/vm/halt_test.rb | 1 - .../actions/vm/move_hard_drive_test.rb | 8 +-- test/vagrant/actions/vm/package_test.rb | 2 - test/vagrant/actions/vm/provision_test.rb | 17 ++---- test/vagrant/actions/vm/reload_test.rb | 1 - test/vagrant/actions/vm/resume_test.rb | 1 - .../vagrant/actions/vm/shared_folders_test.rb | 1 - test/vagrant/actions/vm/start_test.rb | 1 - test/vagrant/actions/vm/suspend_test.rb | 1 - test/vagrant/actions/vm/up_test.rb | 1 - test/vagrant/active_list_test.rb | 2 - test/vagrant/environment_test.rb | 4 -- test/vagrant/provisioners/chef_server_test.rb | 2 - test/vagrant/provisioners/chef_solo_test.rb | 5 -- test/vagrant/provisioners/chef_test.rb | 5 -- test/vagrant/ssh_test.rb | 4 -- test/vagrant/vm_test.rb | 1 - 27 files changed, 7 insertions(+), 114 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index b12dc282c..c163d6133 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -74,61 +74,6 @@ class Test::Unit::TestCase environment end - # Clears the previous config and sets up the new config - def mock_config - Vagrant::Config.reset! - - Vagrant::Config.run do |config| - config.vagrant.dotfile_name = ".vagrant" - - config.ssh.username = "foo" - config.ssh.password = "bar" - config.ssh.host = "baz" - config.ssh.forwarded_port_key = "ssh" - config.ssh.max_tries = 10 - config.ssh.timeout = 10 - config.ssh.private_key_path = '~/foo' - - config.vm.box = "foo" - config.vm.box_ovf = "box.ovf" - config.vm.base_mac = "42" - config.vm.project_directory = "/vagrant" - config.vm.disk_image_format = 'VMDK' - config.vm.forward_port("ssh", 22, 2222) - config.vm.shared_folder_uid = nil - config.vm.shared_folder_gid = nil - - config.package.name = 'vagrant' - config.package.extension = '.box' - - # Chef - config.chef.chef_server_url = "http://localhost:4000" - config.chef.validation_key_path = "validation.pem" - config.chef.client_key_path = "/zoo/foo/bar.pem" - config.chef.cookbooks_path = "cookbooks" - config.chef.provisioning_path = "/tmp/vagrant-chef" - config.chef.json = { - :recipes => ["vagrant_main"] - } - - config.vagrant.home = '~/.home' - end - - if block_given? - Vagrant::Config.run do |config| - yield config - end - end - - if block_given? - Vagrant::Config.run do |config| - yield config - end - end - - Vagrant::Config.execute! - end - # Sets up the mocks and instantiates an action for testing def mock_action(action_klass, *args) vm = mock("vboxvm") diff --git a/test/vagrant/actions/box/add_test.rb b/test/vagrant/actions/box/add_test.rb index bb18dc6bf..ef42fb4a2 100644 --- a/test/vagrant/actions/box/add_test.rb +++ b/test/vagrant/actions/box/add_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class AddBoxActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Add) - mock_config end context "prepare" do diff --git a/test/vagrant/actions/box/destroy_test.rb b/test/vagrant/actions/box/destroy_test.rb index 62e6e245b..741aa7e0d 100644 --- a/test/vagrant/actions/box/destroy_test.rb +++ b/test/vagrant/actions/box/destroy_test.rb @@ -6,7 +6,6 @@ class DestroyBoxActionTest < Test::Unit::TestCase @dir = "foo" @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Destroy) @runner.stubs(:directory).returns(@dir) - mock_config end context "executing" do diff --git a/test/vagrant/actions/box/download_test.rb b/test/vagrant/actions/box/download_test.rb index 2bb3e5cee..71fda7802 100644 --- a/test/vagrant/actions/box/download_test.rb +++ b/test/vagrant/actions/box/download_test.rb @@ -6,7 +6,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Download) @runner.stubs(:uri).returns(@uri) @runner.stubs(:temp_path=) - mock_config @runner.env.stubs(:tmp_path).returns("foo") end diff --git a/test/vagrant/actions/box/unpackage_test.rb b/test/vagrant/actions/box/unpackage_test.rb index ff5141bec..276ec927b 100644 --- a/test/vagrant/actions/box/unpackage_test.rb +++ b/test/vagrant/actions/box/unpackage_test.rb @@ -5,7 +5,6 @@ class UnpackageBoxActionTest < Test::Unit::TestCase @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Unpackage) @runner.stubs(:name).returns("foo") @runner.stubs(:temp_path).returns("bar") - mock_config @runner.env.stubs(:boxes_path).returns("bar") end diff --git a/test/vagrant/actions/vm/boot_test.rb b/test/vagrant/actions/vm/boot_test.rb index 00c94ec54..9ef61e7b2 100644 --- a/test/vagrant/actions/vm/boot_test.rb +++ b/test/vagrant/actions/vm/boot_test.rb @@ -4,7 +4,6 @@ class BootActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Boot) @runner.stubs(:invoke_callback) - mock_config end context "preparing" do diff --git a/test/vagrant/actions/vm/customize_test.rb b/test/vagrant/actions/vm/customize_test.rb index 66e46dbcf..21589e6d0 100644 --- a/test/vagrant/actions/vm/customize_test.rb +++ b/test/vagrant/actions/vm/customize_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class CustomizeActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Customize) - mock_config end context "executing" do diff --git a/test/vagrant/actions/vm/down_test.rb b/test/vagrant/actions/vm/down_test.rb index 0d2b7b444..4966d355b 100644 --- a/test/vagrant/actions/vm/down_test.rb +++ b/test/vagrant/actions/vm/down_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class DownActionTest < Test::Unit::TestCase setup do @mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Down) - mock_config end context "preparing" do diff --git a/test/vagrant/actions/vm/export_test.rb b/test/vagrant/actions/vm/export_test.rb index 1228a9fcd..bdf4eb72c 100644 --- a/test/vagrant/actions/vm/export_test.rb +++ b/test/vagrant/actions/vm/export_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class ExportActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Export) - mock_config end context "executing" do diff --git a/test/vagrant/actions/vm/forward_ports_test.rb b/test/vagrant/actions/vm/forward_ports_test.rb index 8516c2064..18c1ef578 100644 --- a/test/vagrant/actions/vm/forward_ports_test.rb +++ b/test/vagrant/actions/vm/forward_ports_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class ForwardPortsActionTest < Test::Unit::TestCase setup do @mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::ForwardPorts) - mock_config end context "checking for colliding ports" do diff --git a/test/vagrant/actions/vm/halt_test.rb b/test/vagrant/actions/vm/halt_test.rb index 74c5e6501..b08e7ba8b 100644 --- a/test/vagrant/actions/vm/halt_test.rb +++ b/test/vagrant/actions/vm/halt_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class HaltActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Halt) - mock_config end context "executing" do diff --git a/test/vagrant/actions/vm/move_hard_drive_test.rb b/test/vagrant/actions/vm/move_hard_drive_test.rb index f275493e0..3930918e5 100644 --- a/test/vagrant/actions/vm/move_hard_drive_test.rb +++ b/test/vagrant/actions/vm/move_hard_drive_test.rb @@ -4,10 +4,8 @@ class MoveHardDriveActionTest < Test::Unit::TestCase setup do @mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::MoveHardDrive) @hd_location = "/foo" - mock_config do |config| - File.expects(:directory?).with(@hd_location).returns(true) - config.vm.hd_location = @hd_location - end + + @mock_vm.env.config.vm.stubs(:hd_location).returns(@hd_location) end @@ -51,7 +49,7 @@ class MoveHardDriveActionTest < Test::Unit::TestCase end should "be the configured hd location and the existing hard drive filename" do - joined = File.join(Vagrant.config.vm.hd_location, @filename) + joined = File.join(@mock_vm.env.config.vm.hd_location, @filename) assert_equal joined, @action.new_image_path end end diff --git a/test/vagrant/actions/vm/package_test.rb b/test/vagrant/actions/vm/package_test.rb index 1325622ea..92e04badc 100644 --- a/test/vagrant/actions/vm/package_test.rb +++ b/test/vagrant/actions/vm/package_test.rb @@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class PackageActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Package, "bing", []) - - mock_config end context "initialization" do diff --git a/test/vagrant/actions/vm/provision_test.rb b/test/vagrant/actions/vm/provision_test.rb index 468dc4f64..85f895334 100644 --- a/test/vagrant/actions/vm/provision_test.rb +++ b/test/vagrant/actions/vm/provision_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class ProvisionActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Provision) - mock_config end context "initialization" do @@ -29,9 +28,7 @@ class ProvisionActionTest < Test::Unit::TestCase context "preparing" do context "with a nil provisioner" do setup do - mock_config do |config| - config.vm.provisioner = nil - end + @runner.env.config.vm.provisioner = nil end should "not set a provisioner if set to nil" do @@ -49,9 +46,7 @@ class ProvisionActionTest < Test::Unit::TestCase @klass.stubs(:is_a?).with(Class).returns(true) @klass.stubs(:new).with(@runner.env).returns(@instance) - mock_config do |config| - config.vm.provisioner = @klass - end + @runner.env.config.vm.provisioner = @klass end should "set the provisioner to an instantiation of the class" do @@ -75,9 +70,7 @@ class ProvisionActionTest < Test::Unit::TestCase context "with a Symbol provisioner" do def provisioner_expectation(symbol, provisioner) - mock_config do |config| - config.vm.provisioner = symbol - end + @runner.env.config.vm.provisioner = symbol instance = mock("instance") instance.expects(:prepare).once @@ -87,9 +80,7 @@ class ProvisionActionTest < Test::Unit::TestCase end should "raise an ActionException if its an unknown symbol" do - mock_config do |config| - config.vm.provisioner = :this_will_never_exist - end + @runner.env.config.vm.provisioner = :this_will_never_exist assert_raises(Vagrant::Actions::ActionException) { @action.prepare diff --git a/test/vagrant/actions/vm/reload_test.rb b/test/vagrant/actions/vm/reload_test.rb index b2d77fef1..ebc3e8599 100644 --- a/test/vagrant/actions/vm/reload_test.rb +++ b/test/vagrant/actions/vm/reload_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class ReloadActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Reload) - mock_config end context "sub-actions" do diff --git a/test/vagrant/actions/vm/resume_test.rb b/test/vagrant/actions/vm/resume_test.rb index 5429948ad..37558b1cd 100644 --- a/test/vagrant/actions/vm/resume_test.rb +++ b/test/vagrant/actions/vm/resume_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class ResumeActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Resume) - mock_config end context "executing" do diff --git a/test/vagrant/actions/vm/shared_folders_test.rb b/test/vagrant/actions/vm/shared_folders_test.rb index dd9e1bb0a..503559c02 100644 --- a/test/vagrant/actions/vm/shared_folders_test.rb +++ b/test/vagrant/actions/vm/shared_folders_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class SharedFoldersActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::SharedFolders) - mock_config end def stub_shared_folders diff --git a/test/vagrant/actions/vm/start_test.rb b/test/vagrant/actions/vm/start_test.rb index f7d159e0b..a42e51bf8 100644 --- a/test/vagrant/actions/vm/start_test.rb +++ b/test/vagrant/actions/vm/start_test.rb @@ -3,7 +3,6 @@ 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) - mock_config end context "sub-actions" do diff --git a/test/vagrant/actions/vm/suspend_test.rb b/test/vagrant/actions/vm/suspend_test.rb index e296b7011..c5c769189 100644 --- a/test/vagrant/actions/vm/suspend_test.rb +++ b/test/vagrant/actions/vm/suspend_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class SuspendActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Suspend) - mock_config end context "executing" do diff --git a/test/vagrant/actions/vm/up_test.rb b/test/vagrant/actions/vm/up_test.rb index 56ec9d56f..ff63eabdb 100644 --- a/test/vagrant/actions/vm/up_test.rb +++ b/test/vagrant/actions/vm/up_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class UpActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Up) - mock_config end context "sub-actions" do diff --git a/test/vagrant/active_list_test.rb b/test/vagrant/active_list_test.rb index 79043bcac..1c4bed92d 100644 --- a/test/vagrant/active_list_test.rb +++ b/test/vagrant/active_list_test.rb @@ -2,8 +2,6 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper') class ActiveListTest < Test::Unit::TestCase setup do - mock_config - @env = mock_environment @list = Vagrant::ActiveList.new(@env) end diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index 800fd78e4..15627e4ba 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -1,10 +1,6 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper') class EnvironmentTest < Test::Unit::TestCase - setup do - mock_config - end - context "class method check virtualbox version" do setup do VirtualBox.stubs(:version).returns("3.1.4") diff --git a/test/vagrant/provisioners/chef_server_test.rb b/test/vagrant/provisioners/chef_server_test.rb index b28b2b64c..348a47366 100644 --- a/test/vagrant/provisioners/chef_server_test.rb +++ b/test/vagrant/provisioners/chef_server_test.rb @@ -4,8 +4,6 @@ class ChefServerProvisionerTest < Test::Unit::TestCase setup do @env = mock_environment @action = Vagrant::Provisioners::ChefServer.new(@env) - - mock_config end context "provisioning" do diff --git a/test/vagrant/provisioners/chef_solo_test.rb b/test/vagrant/provisioners/chef_solo_test.rb index 6c8d20e10..bc3448d4b 100644 --- a/test/vagrant/provisioners/chef_solo_test.rb +++ b/test/vagrant/provisioners/chef_solo_test.rb @@ -4,11 +4,6 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase setup do @env = mock_environment @action = Vagrant::Provisioners::ChefSolo.new(@env) - - Vagrant::SSH.stubs(:execute) - Vagrant::SSH.stubs(:upload!) - - mock_config end context "preparing" do diff --git a/test/vagrant/provisioners/chef_test.rb b/test/vagrant/provisioners/chef_test.rb index 34b00f7c6..1eda93676 100644 --- a/test/vagrant/provisioners/chef_test.rb +++ b/test/vagrant/provisioners/chef_test.rb @@ -4,11 +4,6 @@ class ChefProvisionerTest < Test::Unit::TestCase setup do @env = mock_environment @action = Vagrant::Provisioners::Chef.new(@env) - - Vagrant::SSH.stubs(:execute) - Vagrant::SSH.stubs(:upload!) - - mock_config end context "preparing" do diff --git a/test/vagrant/ssh_test.rb b/test/vagrant/ssh_test.rb index cbe9793fb..77c7d94b6 100644 --- a/test/vagrant/ssh_test.rb +++ b/test/vagrant/ssh_test.rb @@ -1,10 +1,6 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper') class SshTest < Test::Unit::TestCase - setup do - mock_config - end - def mock_ssh @env = mock_environment do |config| yield config if block_given? diff --git a/test/vagrant/vm_test.rb b/test/vagrant/vm_test.rb index 9d468eb05..e49066b00 100644 --- a/test/vagrant/vm_test.rb +++ b/test/vagrant/vm_test.rb @@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper') class VMTest < Test::Unit::TestCase setup do @mock_vm = mock("vm") - mock_config @persisted_vm = mock("persisted_vm")