Remove old test mocks from the pre-instanced environment days

This commit is contained in:
Mitchell Hashimoto 2010-04-08 23:28:53 -07:00
parent 008e533c98
commit 4e54cc77a2
27 changed files with 7 additions and 114 deletions

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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")