Create a "dummy" provider for tests

This commit is contained in:
Mitchell Hashimoto 2012-12-22 20:03:39 -08:00
parent ac7958a43b
commit a6e0d3908f
4 changed files with 20 additions and 25 deletions

View File

@ -80,7 +80,7 @@ module Vagrant
# as extra data set on the environment hash for the middleware
# runner.
def action(name, extra_env=nil)
@logger.debug("Calling action: #{name} on provider #{@provider}")
@logger.info("Calling action: #{name} on provider #{@provider}")
# Get the callable from the provider.
callable = @provider.action(name)

View File

@ -10,6 +10,7 @@ $:.unshift File.expand_path("../../", __FILE__)
# Load in helpers
require "support/tempdir"
require "unit/support/dummy_provider"
require "unit/support/shared/base_context"
# Do not buffer output

View File

@ -0,0 +1,16 @@
module VagrantTests
class DummyProviderPlugin < Vagrant.plugin("2")
name "Dummy Provider"
description <<-EOF
This creates a provider named "dummy" which does nothing, so that
the unit tests aren't reliant on VirtualBox (or any other real
provider for that matter).
EOF
provider(:dummy) { DummyProvider }
end
class DummyProvider < Vagrant.plugin("2", :provider)
# No-op
end
end

View File

@ -111,7 +111,7 @@ describe Vagrant::Environment do
describe "primary machine" do
it "should be the only machine if not a multi-machine environment" do
instance.primary_machine(:virtualbox).name.should == instance.machine_names.first
instance.primary_machine(:dummy).name.should == instance.machine_names.first
end
it "should be the machine marked as the primary" do
@ -128,7 +128,7 @@ VF
end
env = environment.create_vagrant_env
env.primary_machine(:virtualbox).name.should == :bar
env.primary_machine(:dummy).name.should == :bar
end
end
@ -282,28 +282,6 @@ VF
machine.config.vagrant.dotfile_name.should == "foo"
end
it "should load a machine configured with a V1 box" do
register_provider("foo")
environment = isolated_environment do |env|
env.vagrantfile(<<-VF)
Vagrant.configure("2") do |config|
config.vm.box = "base"
end
VF
env.box("base", <<-VF)
Vagrant.configure("2") do |config|
config.ssh.port = 100
end
VF
end
env = environment.create_vagrant_env
machine = env.machine(:default, :virtualbox)
machine.config.ssh.port.should == 100
end
it "should load the box configuration for a V2 box" do
register_provider("foo")