From a6e0d3908f150ed80f0730d3d03eb998e65fd318 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 22 Dec 2012 20:03:39 -0800 Subject: [PATCH] Create a "dummy" provider for tests --- lib/vagrant/machine.rb | 2 +- test/unit/base.rb | 1 + test/unit/support/dummy_provider.rb | 16 ++++++++++++++++ test/unit/vagrant/environment_test.rb | 26 ++------------------------ 4 files changed, 20 insertions(+), 25 deletions(-) create mode 100644 test/unit/support/dummy_provider.rb diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 515e83350..5f3d66098 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -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) diff --git a/test/unit/base.rb b/test/unit/base.rb index da7334bd0..f471228a1 100644 --- a/test/unit/base.rb +++ b/test/unit/base.rb @@ -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 diff --git a/test/unit/support/dummy_provider.rb b/test/unit/support/dummy_provider.rb new file mode 100644 index 000000000..1a6f98d9e --- /dev/null +++ b/test/unit/support/dummy_provider.rb @@ -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 diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 901e7bfd3..cddfd9858 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -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")