Remove old test mocks from the pre-instanced environment days
This commit is contained in:
parent
008e533c98
commit
4e54cc77a2
|
@ -74,61 +74,6 @@ class Test::Unit::TestCase
|
||||||
environment
|
environment
|
||||||
end
|
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
|
# Sets up the mocks and instantiates an action for testing
|
||||||
def mock_action(action_klass, *args)
|
def mock_action(action_klass, *args)
|
||||||
vm = mock("vboxvm")
|
vm = mock("vboxvm")
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class AddBoxActionTest < Test::Unit::TestCase
|
class AddBoxActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Add)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Add)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "prepare" do
|
context "prepare" do
|
||||||
|
|
|
@ -6,7 +6,6 @@ class DestroyBoxActionTest < Test::Unit::TestCase
|
||||||
@dir = "foo"
|
@dir = "foo"
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Destroy)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Destroy)
|
||||||
@runner.stubs(:directory).returns(@dir)
|
@runner.stubs(:directory).returns(@dir)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
|
@ -6,7 +6,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Download)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Download)
|
||||||
@runner.stubs(:uri).returns(@uri)
|
@runner.stubs(:uri).returns(@uri)
|
||||||
@runner.stubs(:temp_path=)
|
@runner.stubs(:temp_path=)
|
||||||
mock_config
|
|
||||||
|
|
||||||
@runner.env.stubs(:tmp_path).returns("foo")
|
@runner.env.stubs(:tmp_path).returns("foo")
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,6 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Unpackage)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::Box::Unpackage)
|
||||||
@runner.stubs(:name).returns("foo")
|
@runner.stubs(:name).returns("foo")
|
||||||
@runner.stubs(:temp_path).returns("bar")
|
@runner.stubs(:temp_path).returns("bar")
|
||||||
mock_config
|
|
||||||
|
|
||||||
@runner.env.stubs(:boxes_path).returns("bar")
|
@runner.env.stubs(:boxes_path).returns("bar")
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,6 @@ class BootActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Boot)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Boot)
|
||||||
@runner.stubs(:invoke_callback)
|
@runner.stubs(:invoke_callback)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "preparing" do
|
context "preparing" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class CustomizeActionTest < Test::Unit::TestCase
|
class CustomizeActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Customize)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Customize)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class DownActionTest < Test::Unit::TestCase
|
class DownActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Down)
|
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Down)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "preparing" do
|
context "preparing" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class ExportActionTest < Test::Unit::TestCase
|
class ExportActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Export)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Export)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class ForwardPortsActionTest < Test::Unit::TestCase
|
class ForwardPortsActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::ForwardPorts)
|
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::ForwardPorts)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "checking for colliding ports" do
|
context "checking for colliding ports" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class HaltActionTest < Test::Unit::TestCase
|
class HaltActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Halt)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Halt)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
|
@ -4,10 +4,8 @@ class MoveHardDriveActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::MoveHardDrive)
|
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::MoveHardDrive)
|
||||||
@hd_location = "/foo"
|
@hd_location = "/foo"
|
||||||
mock_config do |config|
|
|
||||||
File.expects(:directory?).with(@hd_location).returns(true)
|
@mock_vm.env.config.vm.stubs(:hd_location).returns(@hd_location)
|
||||||
config.vm.hd_location = @hd_location
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +49,7 @@ class MoveHardDriveActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be the configured hd location and the existing hard drive filename" do
|
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
|
assert_equal joined, @action.new_image_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class PackageActionTest < Test::Unit::TestCase
|
class PackageActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Package, "bing", [])
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Package, "bing", [])
|
||||||
|
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "initialization" do
|
context "initialization" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class ProvisionActionTest < Test::Unit::TestCase
|
class ProvisionActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Provision)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Provision)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "initialization" do
|
context "initialization" do
|
||||||
|
@ -29,9 +28,7 @@ class ProvisionActionTest < Test::Unit::TestCase
|
||||||
context "preparing" do
|
context "preparing" do
|
||||||
context "with a nil provisioner" do
|
context "with a nil provisioner" do
|
||||||
setup do
|
setup do
|
||||||
mock_config do |config|
|
@runner.env.config.vm.provisioner = nil
|
||||||
config.vm.provisioner = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not set a provisioner if set to nil" do
|
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(:is_a?).with(Class).returns(true)
|
||||||
@klass.stubs(:new).with(@runner.env).returns(@instance)
|
@klass.stubs(:new).with(@runner.env).returns(@instance)
|
||||||
|
|
||||||
mock_config do |config|
|
@runner.env.config.vm.provisioner = @klass
|
||||||
config.vm.provisioner = @klass
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "set the provisioner to an instantiation of the class" do
|
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
|
context "with a Symbol provisioner" do
|
||||||
def provisioner_expectation(symbol, provisioner)
|
def provisioner_expectation(symbol, provisioner)
|
||||||
mock_config do |config|
|
@runner.env.config.vm.provisioner = symbol
|
||||||
config.vm.provisioner = symbol
|
|
||||||
end
|
|
||||||
|
|
||||||
instance = mock("instance")
|
instance = mock("instance")
|
||||||
instance.expects(:prepare).once
|
instance.expects(:prepare).once
|
||||||
|
@ -87,9 +80,7 @@ class ProvisionActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "raise an ActionException if its an unknown symbol" do
|
should "raise an ActionException if its an unknown symbol" do
|
||||||
mock_config do |config|
|
@runner.env.config.vm.provisioner = :this_will_never_exist
|
||||||
config.vm.provisioner = :this_will_never_exist
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_raises(Vagrant::Actions::ActionException) {
|
assert_raises(Vagrant::Actions::ActionException) {
|
||||||
@action.prepare
|
@action.prepare
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class ReloadActionTest < Test::Unit::TestCase
|
class ReloadActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Reload)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Reload)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "sub-actions" do
|
context "sub-actions" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class ResumeActionTest < Test::Unit::TestCase
|
class ResumeActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Resume)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Resume)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class SharedFoldersActionTest < Test::Unit::TestCase
|
class SharedFoldersActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::SharedFolders)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::SharedFolders)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_shared_folders
|
def stub_shared_folders
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class StartActionTest < Test::Unit::TestCase
|
class StartActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Start)
|
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Start)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "sub-actions" do
|
context "sub-actions" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class SuspendActionTest < Test::Unit::TestCase
|
class SuspendActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Suspend)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Suspend)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||||
class UpActionTest < Test::Unit::TestCase
|
class UpActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Up)
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Up)
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "sub-actions" do
|
context "sub-actions" do
|
||||||
|
|
|
@ -2,8 +2,6 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
||||||
|
|
||||||
class ActiveListTest < Test::Unit::TestCase
|
class ActiveListTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
mock_config
|
|
||||||
|
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
@list = Vagrant::ActiveList.new(@env)
|
@list = Vagrant::ActiveList.new(@env)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
||||||
|
|
||||||
class EnvironmentTest < Test::Unit::TestCase
|
class EnvironmentTest < Test::Unit::TestCase
|
||||||
setup do
|
|
||||||
mock_config
|
|
||||||
end
|
|
||||||
|
|
||||||
context "class method check virtualbox version" do
|
context "class method check virtualbox version" do
|
||||||
setup do
|
setup do
|
||||||
VirtualBox.stubs(:version).returns("3.1.4")
|
VirtualBox.stubs(:version).returns("3.1.4")
|
||||||
|
|
|
@ -4,8 +4,6 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
@action = Vagrant::Provisioners::ChefServer.new(@env)
|
@action = Vagrant::Provisioners::ChefServer.new(@env)
|
||||||
|
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "provisioning" do
|
context "provisioning" do
|
||||||
|
|
|
@ -4,11 +4,6 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
@action = Vagrant::Provisioners::ChefSolo.new(@env)
|
@action = Vagrant::Provisioners::ChefSolo.new(@env)
|
||||||
|
|
||||||
Vagrant::SSH.stubs(:execute)
|
|
||||||
Vagrant::SSH.stubs(:upload!)
|
|
||||||
|
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "preparing" do
|
context "preparing" do
|
||||||
|
|
|
@ -4,11 +4,6 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
@action = Vagrant::Provisioners::Chef.new(@env)
|
@action = Vagrant::Provisioners::Chef.new(@env)
|
||||||
|
|
||||||
Vagrant::SSH.stubs(:execute)
|
|
||||||
Vagrant::SSH.stubs(:upload!)
|
|
||||||
|
|
||||||
mock_config
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "preparing" do
|
context "preparing" do
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
||||||
|
|
||||||
class SshTest < Test::Unit::TestCase
|
class SshTest < Test::Unit::TestCase
|
||||||
setup do
|
|
||||||
mock_config
|
|
||||||
end
|
|
||||||
|
|
||||||
def mock_ssh
|
def mock_ssh
|
||||||
@env = mock_environment do |config|
|
@env = mock_environment do |config|
|
||||||
yield config if block_given?
|
yield config if block_given?
|
||||||
|
|
|
@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
||||||
class VMTest < Test::Unit::TestCase
|
class VMTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@mock_vm = mock("vm")
|
@mock_vm = mock("vm")
|
||||||
mock_config
|
|
||||||
|
|
||||||
@persisted_vm = mock("persisted_vm")
|
@persisted_vm = mock("persisted_vm")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue