Remove most of the remaining mock_environment calls. Only one remains.
This commit is contained in:
parent
8164644615
commit
73c223c885
|
@ -112,24 +112,6 @@ class Test::Unit::TestCase
|
||||||
[app, env]
|
[app, env]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a resource logger which is safe for tests
|
|
||||||
def quiet_logger(resource, env=nil)
|
|
||||||
logger = Vagrant::ResourceLogger.new(resource, env)
|
|
||||||
logger.stubs(:flush_progress)
|
|
||||||
logger.stubs(:cl_reset).returns("")
|
|
||||||
logger
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a linux system
|
|
||||||
def linux_system(vm)
|
|
||||||
Vagrant::Systems::Linux.new(vm)
|
|
||||||
end
|
|
||||||
|
|
||||||
def stub_default_action_dependecies(mock)
|
|
||||||
mock.stubs(:precedes).returns([])
|
|
||||||
mock.stubs(:follows).returns([])
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets up the mocks and stubs for a downloader
|
# Sets up the mocks and stubs for a downloader
|
||||||
def mock_downloader(downloader_klass)
|
def mock_downloader(downloader_klass)
|
||||||
tempfile = mock("tempfile")
|
tempfile = mock("tempfile")
|
||||||
|
|
|
@ -30,18 +30,19 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not raise an exception if validation_key_path is set" do
|
should "not raise an exception if validation_key_path is set" do
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env(vagrantfile(<<-vf))
|
||||||
config.chef.validation_key_path = "7"
|
config.chef.validation_key_path = "7"
|
||||||
end
|
config.chef.chef_server_url = "7"
|
||||||
|
vf
|
||||||
|
|
||||||
@action.stubs(:env).returns(@env)
|
@action.stubs(:env).returns(@env)
|
||||||
assert_nothing_raised { @action.prepare }
|
assert_nothing_raised { @action.prepare }
|
||||||
end
|
end
|
||||||
|
|
||||||
should "raise an exception if validation_key_path is nil" do
|
should "raise an exception if validation_key_path is nil" do
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env(vagrantfile(<<-vf))
|
||||||
config.chef.validation_key_path = nil
|
config.chef.validation_key_path = nil
|
||||||
end
|
vf
|
||||||
|
|
||||||
@action.stubs(:env).returns(@env)
|
@action.stubs(:env).returns(@env)
|
||||||
|
|
||||||
|
@ -51,21 +52,20 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not raise an exception if validation_key_path does exist" do
|
should "not raise an exception if validation_key_path does exist" do
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env(vagrantfile(<<-vf))
|
||||||
config.chef.validation_key_path = "7"
|
config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
|
||||||
end
|
config.chef.chef_server_url = "7"
|
||||||
|
vf
|
||||||
|
|
||||||
@action.stubs(:env).returns(@env)
|
@action.stubs(:env).returns(@env)
|
||||||
@action.stubs(:validation_key_path).returns("9")
|
|
||||||
|
|
||||||
File.expects(:file?).with(@action.validation_key_path).returns(true)
|
|
||||||
assert_nothing_raised { @action.prepare }
|
assert_nothing_raised { @action.prepare }
|
||||||
end
|
end
|
||||||
|
|
||||||
should "raise an exception if validation_key_path doesn't exist" do
|
should "raise an exception if validation_key_path doesn't exist" do
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env(vagrantfile(<<-vf))
|
||||||
config.chef.validation_key_path = "7"
|
config.chef.validation_key_path = "7"
|
||||||
end
|
config.chef.chef_server_url = "7"
|
||||||
|
vf
|
||||||
|
|
||||||
@action.stubs(:env).returns(@env)
|
@action.stubs(:env).returns(@env)
|
||||||
@action.stubs(:validation_key_path).returns("9")
|
@action.stubs(:validation_key_path).returns("9")
|
||||||
|
@ -77,18 +77,19 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not raise an exception if chef_server_url is set" do
|
should "not raise an exception if chef_server_url is set" do
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env(vagrantfile(<<-vf))
|
||||||
|
config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
|
||||||
config.chef.chef_server_url = "7"
|
config.chef.chef_server_url = "7"
|
||||||
end
|
vf
|
||||||
|
|
||||||
@action.stubs(:env).returns(@env)
|
@action.stubs(:env).returns(@env)
|
||||||
assert_nothing_raised { @action.prepare }
|
assert_nothing_raised { @action.prepare }
|
||||||
end
|
end
|
||||||
|
|
||||||
should "raise an exception if chef_server_url is nil" do
|
should "raise an exception if chef_server_url is nil" do
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env(vagrantfile(<<-vf))
|
||||||
config.chef.chef_server_url = nil
|
config.chef.chef_server_url = nil
|
||||||
end
|
vf
|
||||||
|
|
||||||
@action.stubs(:env).returns(@env)
|
@action.stubs(:env).returns(@env)
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,7 @@ require "test_helper"
|
||||||
|
|
||||||
class SshTest < Test::Unit::TestCase
|
class SshTest < Test::Unit::TestCase
|
||||||
def mock_ssh
|
def mock_ssh
|
||||||
@env = mock_environment do |config|
|
@env = vagrant_env
|
||||||
yield config if block_given?
|
|
||||||
end
|
|
||||||
|
|
||||||
@forwarded_ports = []
|
|
||||||
@network_adapters = []
|
@network_adapters = []
|
||||||
@vm = mock("vm")
|
@vm = mock("vm")
|
||||||
@vm.stubs(:network_adapters).returns(@network_adapters)
|
@vm.stubs(:network_adapters).returns(@network_adapters)
|
||||||
|
@ -18,7 +14,7 @@ class SshTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
VirtualBox.stubs(:version).returns("3.1.4")
|
VirtualBox.stubs(:version).returns("3.2.4")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "connecting to external SSH" do
|
context "connecting to external SSH" do
|
||||||
|
|
|
@ -100,10 +100,10 @@ class LinuxSystemTest < Test::Unit::TestCase
|
||||||
should "add uid AND gid to mount" do
|
should "add uid AND gid to mount" do
|
||||||
uid = "foo"
|
uid = "foo"
|
||||||
gid = "bar"
|
gid = "bar"
|
||||||
env = mock_environment do |config|
|
env = vagrant_env(vagrantfile(<<-vf))
|
||||||
config.vm.shared_folder_uid = uid
|
config.vm.shared_folder_uid = "#{uid}"
|
||||||
config.vm.shared_folder_gid = gid
|
config.vm.shared_folder_gid = "#{gid}"
|
||||||
end
|
vf
|
||||||
|
|
||||||
@vm.stubs(:env).returns(env)
|
@vm.stubs(:env).returns(env)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue