Create a "dummy" provider for tests
This commit is contained in:
parent
ac7958a43b
commit
a6e0d3908f
|
@ -80,7 +80,7 @@ module Vagrant
|
||||||
# as extra data set on the environment hash for the middleware
|
# as extra data set on the environment hash for the middleware
|
||||||
# runner.
|
# runner.
|
||||||
def action(name, extra_env=nil)
|
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.
|
# Get the callable from the provider.
|
||||||
callable = @provider.action(name)
|
callable = @provider.action(name)
|
||||||
|
|
|
@ -10,6 +10,7 @@ $:.unshift File.expand_path("../../", __FILE__)
|
||||||
|
|
||||||
# Load in helpers
|
# Load in helpers
|
||||||
require "support/tempdir"
|
require "support/tempdir"
|
||||||
|
require "unit/support/dummy_provider"
|
||||||
require "unit/support/shared/base_context"
|
require "unit/support/shared/base_context"
|
||||||
|
|
||||||
# Do not buffer output
|
# Do not buffer output
|
||||||
|
|
|
@ -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
|
|
@ -111,7 +111,7 @@ describe Vagrant::Environment do
|
||||||
|
|
||||||
describe "primary machine" do
|
describe "primary machine" do
|
||||||
it "should be the only machine if not a multi-machine environment" 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
|
end
|
||||||
|
|
||||||
it "should be the machine marked as the primary" do
|
it "should be the machine marked as the primary" do
|
||||||
|
@ -128,7 +128,7 @@ VF
|
||||||
end
|
end
|
||||||
|
|
||||||
env = environment.create_vagrant_env
|
env = environment.create_vagrant_env
|
||||||
env.primary_machine(:virtualbox).name.should == :bar
|
env.primary_machine(:dummy).name.should == :bar
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -282,28 +282,6 @@ VF
|
||||||
machine.config.vagrant.dotfile_name.should == "foo"
|
machine.config.vagrant.dotfile_name.should == "foo"
|
||||||
end
|
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
|
it "should load the box configuration for a V2 box" do
|
||||||
register_provider("foo")
|
register_provider("foo")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue