Get rid of "mock_action_data" use "action_env" instead

This commit is contained in:
Mitchell Hashimoto 2010-09-08 23:56:35 -07:00
parent 16f3a3face
commit a0ed4d0da8
27 changed files with 32 additions and 38 deletions

View File

@ -37,20 +37,12 @@ class Test::Unit::TestCase
vm vm
end end
def mock_action_data(v_env=nil)
v_env ||= vagrant_env
app = lambda { |env| }
env = Vagrant::Action::Environment.new(v_env)
env["vagrant.test"] = true
[app, env]
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")
tempfile.stubs(:write) tempfile.stubs(:write)
_, env = mock_action_data _, env = action_env
[downloader_klass.new(env), tempfile] [downloader_klass.new(env), tempfile]
end end
end end

View File

@ -3,7 +3,7 @@ require "test_helper"
class SetEnvActionTest < Test::Unit::TestCase class SetEnvActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::Env::Set @klass = Vagrant::Action::Env::Set
@app, @env = mock_action_data @app, @env = action_env
@env.clear @env.clear
end end

View File

@ -3,7 +3,7 @@ require "test_helper"
class PackageGeneralActionTest < Test::Unit::TestCase class PackageGeneralActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::General::Package @klass = Vagrant::Action::General::Package
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class BootVMActionTest < Test::Unit::TestCase class BootVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Boot @klass = Vagrant::Action::VM::Boot
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:ssh).returns(mock("ssh")) @vm.stubs(:ssh).returns(mock("ssh"))

View File

@ -3,7 +3,7 @@ require "test_helper"
class CleanMachineFolderVMActionTest < Test::Unit::TestCase class CleanMachineFolderVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::CleanMachineFolder @klass = Vagrant::Action::VM::CleanMachineFolder
@app, @env = mock_action_data @app, @env = action_env
@instance = @klass.new(@app, @env) @instance = @klass.new(@app, @env)
end end

View File

@ -3,7 +3,7 @@ require "test_helper"
class ClearForwardedPortsVMActionTest < Test::Unit::TestCase class ClearForwardedPortsVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::ClearForwardedPorts @klass = Vagrant::Action::VM::ClearForwardedPorts
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -3,7 +3,7 @@ require "test_helper"
class ClearNFSExportsActionTest < Test::Unit::TestCase class ClearNFSExportsActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::ClearNFSExports @klass = Vagrant::Action::VM::ClearNFSExports
@app, @env = mock_action_data @app, @env = action_env
@env.env.stubs(:host).returns(Vagrant::Hosts::Base.new(@env)) @env.env.stubs(:host).returns(Vagrant::Hosts::Base.new(@env))
@instance = @klass.new(@app, @env) @instance = @klass.new(@app, @env)

View File

@ -3,7 +3,7 @@ require "test_helper"
class ClearSharedFoldersVMActionTest < Test::Unit::TestCase class ClearSharedFoldersVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::ClearSharedFolders @klass = Vagrant::Action::VM::ClearSharedFolders
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class CustomizeVMActionTest < Test::Unit::TestCase class CustomizeVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Customize @klass = Vagrant::Action::VM::Customize
@app, @env = mock_action_data @app, @env = action_env
@instance = @klass.new(@app, @env) @instance = @klass.new(@app, @env)
@vm = mock("vm") @vm = mock("vm")

View File

@ -3,7 +3,7 @@ require "test_helper"
class DestroyVMActionTest < Test::Unit::TestCase class DestroyVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Destroy @klass = Vagrant::Action::VM::Destroy
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class DestroyUnusedNetworkInterfacesVMActionTest < Test::Unit::TestCase class DestroyUnusedNetworkInterfacesVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::DestroyUnusedNetworkInterfaces @klass = Vagrant::Action::VM::DestroyUnusedNetworkInterfaces
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class DisableNetworksVMActionTest < Test::Unit::TestCase class DisableNetworksVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::DisableNetworks @klass = Vagrant::Action::VM::DisableNetworks
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env.env.stubs(:vm).returns(@vm) @env.env.stubs(:vm).returns(@vm)

View File

@ -3,7 +3,7 @@ require "test_helper"
class DiscardStateVMActionTest < Test::Unit::TestCase class DiscardStateVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::DiscardState @klass = Vagrant::Action::VM::DiscardState
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class ExportVMActionTest < Test::Unit::TestCase class ExportVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Export @klass = Vagrant::Action::VM::Export
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,11 +3,11 @@ require "test_helper"
class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Class.new do @klass = Class.new do
include Vagrant::Action::VM::ForwardPortsHelpers
def initialize(env); @env = env; end def initialize(env); @env = env; end
end end
@klass.send(:include, Vagrant::Action::VM::ForwardPortsHelpers) @app, @env = action_env
@app, @env = mock_action_data
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -3,7 +3,7 @@ require "test_helper"
class ForwardPortsVMActionTest < Test::Unit::TestCase class ForwardPortsVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::ForwardPorts @klass = Vagrant::Action::VM::ForwardPorts
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -3,7 +3,7 @@ require "test_helper"
class HaltVMActionTest < Test::Unit::TestCase class HaltVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Halt @klass = Vagrant::Action::VM::Halt
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -3,7 +3,7 @@ require "test_helper"
class ImportVMActionTest < Test::Unit::TestCase class ImportVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Import @klass = Vagrant::Action::VM::Import
@app, @env = mock_action_data @app, @env = action_env
@instance = @klass.new(@app, @env) @instance = @klass.new(@app, @env)
ovf_file = "foo" ovf_file = "foo"

View File

@ -3,7 +3,7 @@ require "test_helper"
class MatchMACAddressVMActionTest < Test::Unit::TestCase class MatchMACAddressVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::MatchMACAddress @klass = Vagrant::Action::VM::MatchMACAddress
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class NetworkVMActionTest < Test::Unit::TestCase class NetworkVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Network @klass = Vagrant::Action::VM::Network
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -2,9 +2,11 @@ require "test_helper"
class NFSHelpersVMActionTest < Test::Unit::TestCase class NFSHelpersVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Class.new @klass = Class.new do
@klass.send(:include, Vagrant::Action::VM::NFSHelpers) include Vagrant::Action::VM::NFSHelpers
@app, @env = mock_action_data end
@app, @env = action_env
@instance = @klass.new @instance = @klass.new
end end

View File

@ -3,7 +3,7 @@ require "test_helper"
class PackageVMActionTest < Test::Unit::TestCase class PackageVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Package @klass = Vagrant::Action::VM::Package
@app, @env = mock_action_data @app, @env = action_env
@env["export.temp_dir"] = "foo" @env["export.temp_dir"] = "foo"
@instance = @klass.new(@app, @env) @instance = @klass.new(@app, @env)

View File

@ -3,7 +3,7 @@ require "test_helper"
class PackageVagrantfileVMActionTest < Test::Unit::TestCase class PackageVagrantfileVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::PackageVagrantfile @klass = Vagrant::Action::VM::PackageVagrantfile
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class ProvisionVMActionTest < Test::Unit::TestCase class ProvisionVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Provision @klass = Vagrant::Action::VM::Provision
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -3,7 +3,7 @@ require "test_helper"
class ResumeVMActionTest < Test::Unit::TestCase class ResumeVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Resume @klass = Vagrant::Action::VM::Resume
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm

View File

@ -3,7 +3,7 @@ require "test_helper"
class ShareFoldersVMActionTest < Test::Unit::TestCase class ShareFoldersVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::ShareFolders @klass = Vagrant::Action::VM::ShareFolders
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@vm.stubs(:name).returns("foo") @vm.stubs(:name).returns("foo")

View File

@ -3,7 +3,7 @@ require "test_helper"
class SuspendVMActionTest < Test::Unit::TestCase class SuspendVMActionTest < Test::Unit::TestCase
setup do setup do
@klass = Vagrant::Action::VM::Suspend @klass = Vagrant::Action::VM::Suspend
@app, @env = mock_action_data @app, @env = action_env
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm