Converted most "mock_environment" tests to "vagrant_env" which uses real filesystem
This commit is contained in:
parent
3cca2f1bb4
commit
8164644615
|
@ -97,7 +97,7 @@ class Test::Unit::TestCase
|
|||
|
||||
# Sets up the mocks for a VM
|
||||
def mock_vm(env=nil)
|
||||
env ||= mock_environment
|
||||
env ||= vagrant_env
|
||||
vm = Vagrant::VM.new
|
||||
vm.stubs(:env).returns(env)
|
||||
vm.stubs(:ssh).returns(Vagrant::SSH.new(vm.env))
|
||||
|
|
|
@ -3,14 +3,8 @@ require "test_helper"
|
|||
class DestroyBoxActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Box::Destroy
|
||||
@app, @env = mock_action_data
|
||||
|
||||
@vm = mock("vm")
|
||||
@env["vm"] = @vm
|
||||
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
||||
|
||||
@internal_vm = mock("internal")
|
||||
@vm.stubs(:vm).returns(@internal_vm)
|
||||
@app, @env = action_env
|
||||
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
||||
|
||||
@instance = @klass.new(@app, @env)
|
||||
end
|
||||
|
|
|
@ -3,15 +3,9 @@ require "test_helper"
|
|||
class DownloadBoxActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Box::Download
|
||||
@app, @env = mock_action_data
|
||||
|
||||
@vm = mock("vm")
|
||||
@env["vm"] = @vm
|
||||
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
||||
@app, @env = action_env
|
||||
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
||||
@env["box"].uri = "http://google.com"
|
||||
|
||||
@internal_vm = mock("internal")
|
||||
@vm.stubs(:vm).returns(@internal_vm)
|
||||
end
|
||||
|
||||
context "initializing" do
|
||||
|
|
|
@ -3,8 +3,8 @@ require "test_helper"
|
|||
class PackageBoxActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Box::Package
|
||||
@app, @env = mock_action_data
|
||||
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
||||
@app, @env = action_env
|
||||
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
||||
|
||||
@instance = @klass.new(@app, @env)
|
||||
end
|
||||
|
|
|
@ -3,14 +3,8 @@ require "test_helper"
|
|||
class UnpackageBoxActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Box::Unpackage
|
||||
@app, @env = mock_action_data
|
||||
|
||||
@vm = mock("vm")
|
||||
@env["vm"] = @vm
|
||||
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
||||
|
||||
@internal_vm = mock("internal")
|
||||
@vm.stubs(:vm).returns(@internal_vm)
|
||||
@app, @env = action_env
|
||||
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
||||
|
||||
@instance = @klass.new(@app, @env)
|
||||
end
|
||||
|
|
|
@ -3,14 +3,8 @@ require "test_helper"
|
|||
class VerifyBoxActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Box::Verify
|
||||
@app, @env = mock_action_data
|
||||
|
||||
@vm = mock("vm")
|
||||
@env["vm"] = @vm
|
||||
@env["box"] = Vagrant::Box.new(mock_environment, "foo")
|
||||
|
||||
@internal_vm = mock("internal")
|
||||
@vm.stubs(:vm).returns(@internal_vm)
|
||||
@app, @env = action_env
|
||||
@env["box"] = Vagrant::Box.new(vagrant_env, "foo")
|
||||
|
||||
@instance = @klass.new(@app, @env)
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require "test_helper"
|
|||
class ActionEnvironmentTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Environment
|
||||
@instance = @klass.new(mock_environment)
|
||||
@instance = @klass.new(vagrant_env)
|
||||
end
|
||||
|
||||
should "be a hash with indifferent access" do
|
||||
|
|
|
@ -24,7 +24,7 @@ class ActionTest < Test::Unit::TestCase
|
|||
|
||||
context "with an instance" do
|
||||
setup do
|
||||
@instance = @klass.new(mock_environment)
|
||||
@instance = @klass.new(vagrant_env)
|
||||
end
|
||||
|
||||
should "raise an exception if a nil action is given" do
|
||||
|
|
|
@ -3,7 +3,7 @@ require "test_helper"
|
|||
class BoxTest < Test::Unit::TestCase
|
||||
context "class methods" do
|
||||
setup do
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
end
|
||||
|
||||
context "listing all boxes" do
|
||||
|
@ -112,7 +112,7 @@ class BoxTest < Test::Unit::TestCase
|
|||
context "instance methods" do
|
||||
setup do
|
||||
@box = Vagrant::Box.new
|
||||
@box.env = mock_environment
|
||||
@box.env = vagrant_env
|
||||
end
|
||||
|
||||
should "execute the Add action when add is called" do
|
||||
|
|
|
@ -29,7 +29,7 @@ class CLITest < Test::Unit::TestCase
|
|||
|
||||
name = "__test_registering_with_alias"
|
||||
@klass.register(base, name, name, "A description", :alias => "--ALIAS")
|
||||
assert_raises(RuntimeError) { @klass.start(["--ALIAS"], :env => mock_environment) }
|
||||
assert_raises(RuntimeError) { @klass.start(["--ALIAS"], :env => vagrant_env) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require "test_helper"
|
|||
class CommandBaseTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Command::Base
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
end
|
||||
|
||||
context "initialization" do
|
||||
|
|
|
@ -3,7 +3,7 @@ require "test_helper"
|
|||
class CommandGroupBaseTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Command::GroupBase
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
end
|
||||
|
||||
context "initialization" do
|
||||
|
|
|
@ -18,7 +18,7 @@ class CommandHelpersTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "not raise an exception if environment is given and setup UI" do
|
||||
env = mock_environment
|
||||
env = vagrant_env
|
||||
assert_nothing_raised { command([], env) }
|
||||
assert env.ui.is_a?(Vagrant::UI::Shell)
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ class CommandHelpersTest < Test::Unit::TestCase
|
|||
|
||||
context "vms from args" do
|
||||
setup do
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
@env.stubs(:root_path).returns(7)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ require "test_helper"
|
|||
|
||||
class ConfigSSHTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@env = mock_environment
|
||||
@env.stubs(:root_path).returns("foo")
|
||||
@env = vagrant_env
|
||||
end
|
||||
|
||||
should "expand any path when requesting the value" do
|
||||
|
|
|
@ -4,7 +4,7 @@ class ConfigVMTest < Test::Unit::TestCase
|
|||
setup do
|
||||
@username = "mitchellh"
|
||||
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
@config = @env.config.vm
|
||||
@env.config.ssh.username = @username
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class ConfigTest < Test::Unit::TestCase
|
|||
|
||||
context "with an instance" do
|
||||
setup do
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
@instance = @klass.new(@env)
|
||||
|
||||
# Don't want validation to occur for these tests
|
||||
|
|
|
@ -7,7 +7,7 @@ class BaseDownloaderTest < Test::Unit::TestCase
|
|||
|
||||
context "base instance" do
|
||||
setup do
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
@base = Vagrant::Downloaders::Base.new(@env)
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class BaseHostTest < Test::Unit::TestCase
|
|||
context "class methods" do
|
||||
context "loading" do
|
||||
setup do
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
end
|
||||
|
||||
should "return detected class if klass is nil" do
|
||||
|
|
|
@ -7,7 +7,7 @@ class BaseProvisionerTest < Test::Unit::TestCase
|
|||
|
||||
context "base instance" do
|
||||
setup do
|
||||
@env = Vagrant::Action::Environment.new(mock_environment)
|
||||
@env = Vagrant::Action::Environment.new(vagrant_env)
|
||||
@base = Vagrant::Provisioners::Base.new(@env)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class ChefServerProvisionerTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@action_env = Vagrant::Action::Environment.new(mock_environment)
|
||||
@action_env = Vagrant::Action::Environment.new(vagrant_env)
|
||||
@action_env.env.vm = mock_vm
|
||||
|
||||
@action = Vagrant::Provisioners::ChefServer.new(@action_env)
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class ChefSoloProvisionerTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@action_env = Vagrant::Action::Environment.new(mock_environment)
|
||||
@action_env = Vagrant::Action::Environment.new(vagrant_env)
|
||||
@action_env.env.vm = mock_vm
|
||||
|
||||
@action = Vagrant::Provisioners::ChefSolo.new(@action_env)
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
|
||||
class ChefProvisionerTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@action_env = Vagrant::Action::Environment.new(mock_environment)
|
||||
@action_env = Vagrant::Action::Environment.new(vagrant_env)
|
||||
@action_env.env.vm = mock_vm
|
||||
|
||||
@action = Vagrant::Provisioners::Chef.new(@action_env)
|
||||
|
|
|
@ -4,7 +4,7 @@ class LinuxSystemTest < Test::Unit::TestCase
|
|||
setup do
|
||||
@klass = Vagrant::Systems::Linux
|
||||
@ssh = mock("ssh")
|
||||
@mock_env = mock_environment
|
||||
@mock_env = vagrant_env
|
||||
@vm = mock("vm")
|
||||
@vm.stubs(:env).returns(@mock_env)
|
||||
@instance = @klass.new(@vm)
|
||||
|
|
|
@ -4,7 +4,7 @@ class ShellUITest < Test::Unit::TestCase
|
|||
setup do
|
||||
@klass = Vagrant::UI::Shell
|
||||
@shell = mock("shell")
|
||||
@instance = @klass.new(mock_environment, @shell)
|
||||
@instance = @klass.new(vagrant_env, @shell)
|
||||
end
|
||||
|
||||
context "prefixing with resource" do
|
||||
|
|
|
@ -13,7 +13,7 @@ class ResourceLoggerUtilTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "return a nil plain logger if the config is not loaded" do
|
||||
env = mock_environment
|
||||
env = vagrant_env
|
||||
env.config.stubs(:loaded?).returns(false)
|
||||
|
||||
Vagrant::Util::PlainLogger.expects(:new).with(nil).returns(@result)
|
||||
|
@ -22,7 +22,7 @@ class ResourceLoggerUtilTest < Test::Unit::TestCase
|
|||
|
||||
should "return a logger with the specified output if environment is ready" do
|
||||
output = mock("output")
|
||||
env = mock_environment
|
||||
env = vagrant_env
|
||||
env.config.vagrant.log_output = output
|
||||
|
||||
Vagrant::Util::PlainLogger.expects(:new).with(output).returns(@result)
|
||||
|
@ -31,7 +31,7 @@ class ResourceLoggerUtilTest < Test::Unit::TestCase
|
|||
|
||||
should "only load the logger once" do
|
||||
output = mock("output")
|
||||
env = mock_environment
|
||||
env = vagrant_env
|
||||
env.config.vagrant.log_output = output
|
||||
|
||||
Vagrant::Util::PlainLogger.expects(:new).with(output).returns(@result)
|
||||
|
@ -43,7 +43,7 @@ class ResourceLoggerUtilTest < Test::Unit::TestCase
|
|||
|
||||
context "initialization" do
|
||||
should "setup the logger and attributes" do
|
||||
env = mock_environment
|
||||
env = vagrant_env
|
||||
resource = mock("resource")
|
||||
result = mock("result")
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ResourceLoggerUtilTest < Test::Unit::TestCase
|
|||
context "with an instance" do
|
||||
setup do
|
||||
@resource = "foo"
|
||||
@env = mock_environment
|
||||
@env = vagrant_env
|
||||
@logger = mock("logger")
|
||||
|
||||
@klass.stubs(:singleton_logger).returns(@logger)
|
||||
|
|
Loading…
Reference in New Issue