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]
|
||||
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
|
||||
def mock_downloader(downloader_klass)
|
||||
tempfile = mock("tempfile")
|
||||
|
|
|
@ -30,18 +30,19 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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"
|
||||
end
|
||||
config.chef.chef_server_url = "7"
|
||||
vf
|
||||
|
||||
@action.stubs(:env).returns(@env)
|
||||
assert_nothing_raised { @action.prepare }
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
vf
|
||||
|
||||
@action.stubs(:env).returns(@env)
|
||||
|
||||
|
@ -51,21 +52,20 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "not raise an exception if validation_key_path does exist" do
|
||||
@env = mock_environment do |config|
|
||||
config.chef.validation_key_path = "7"
|
||||
end
|
||||
@env = vagrant_env(vagrantfile(<<-vf))
|
||||
config.chef.validation_key_path = "#{vagrantfile(tmp_path)}"
|
||||
config.chef.chef_server_url = "7"
|
||||
vf
|
||||
|
||||
@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 }
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
config.chef.chef_server_url = "7"
|
||||
vf
|
||||
|
||||
@action.stubs(:env).returns(@env)
|
||||
@action.stubs(:validation_key_path).returns("9")
|
||||
|
@ -77,18 +77,19 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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"
|
||||
end
|
||||
vf
|
||||
|
||||
@action.stubs(:env).returns(@env)
|
||||
assert_nothing_raised { @action.prepare }
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
vf
|
||||
|
||||
@action.stubs(:env).returns(@env)
|
||||
|
||||
|
|
|
@ -2,11 +2,7 @@ require "test_helper"
|
|||
|
||||
class SshTest < Test::Unit::TestCase
|
||||
def mock_ssh
|
||||
@env = mock_environment do |config|
|
||||
yield config if block_given?
|
||||
end
|
||||
|
||||
@forwarded_ports = []
|
||||
@env = vagrant_env
|
||||
@network_adapters = []
|
||||
@vm = mock("vm")
|
||||
@vm.stubs(:network_adapters).returns(@network_adapters)
|
||||
|
@ -18,7 +14,7 @@ class SshTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
setup do
|
||||
VirtualBox.stubs(:version).returns("3.1.4")
|
||||
VirtualBox.stubs(:version).returns("3.2.4")
|
||||
end
|
||||
|
||||
context "connecting to external SSH" do
|
||||
|
|
|
@ -100,10 +100,10 @@ class LinuxSystemTest < Test::Unit::TestCase
|
|||
should "add uid AND gid to mount" do
|
||||
uid = "foo"
|
||||
gid = "bar"
|
||||
env = mock_environment do |config|
|
||||
config.vm.shared_folder_uid = uid
|
||||
config.vm.shared_folder_gid = gid
|
||||
end
|
||||
env = vagrant_env(vagrantfile(<<-vf))
|
||||
config.vm.shared_folder_uid = "#{uid}"
|
||||
config.vm.shared_folder_gid = "#{gid}"
|
||||
vf
|
||||
|
||||
@vm.stubs(:env).returns(env)
|
||||
|
||||
|
|
Loading…
Reference in New Issue