BoxCollection#find should only find V1 box when searching for vbox

This commit is contained in:
Mitchell Hashimoto 2012-11-14 16:12:47 -08:00
parent e2dd0b0cf2
commit 0ec639c8e1
2 changed files with 24 additions and 12 deletions

View File

@ -198,6 +198,9 @@ module Vagrant
return Box.new(name, provider, box_directory.dirname)
end
# If we're looking for a VirtualBox box, then we check if there is
# a V1 box.
if provider == :virtualbox
# Check if a V1 version of this box exists, and if so, raise an
# exception notifying the caller that the box exists but needs
# to be upgraded. We don't do the upgrade here because it can be
@ -211,6 +214,7 @@ module Vagrant
@logger.warn("V1 box found: #{name}")
raise Errors::BoxUpgradeRequired, :name => name
end
end
# Didn't find it, return nil
@logger.info("Box not found: #{name} (#{provider})")

View File

@ -168,6 +168,14 @@ describe Vagrant::BoxCollection do
expect { instance.find("foo", :virtualbox) }.
to raise_error(Vagrant::Errors::BoxUpgradeRequired)
end
it "should return nil if there is a V1 box but we're looking for another provider" do
# Create a V1 box
environment.box1("foo")
# Test
instance.find("foo", :another_provider).should be_nil
end
end
describe "upgrading" do