Exception when you attempt to add a box when a V1 box conflicts.

This commit is contained in:
Mitchell Hashimoto 2012-07-01 21:50:29 -07:00
parent 9e33d16ca1
commit a35f6a175d
2 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,8 @@ module Vagrant
# * BoxAlreadyExists - The box you're attempting to add already exists.
# * BoxProviderDoesntMatch - If the given box provider doesn't match the
# actual box provider in the untarred box.
# * BoxUpgradeRequired - You're attempting to add a box when there is a
# V1 box with the same name that must first be upgraded.
#
# Preconditions:
# * File given in `path` must exist.

View File

@ -37,6 +37,18 @@ describe Vagrant::BoxCollection2 do
to raise_error(Vagrant::Errors::BoxAlreadyExists)
end
it "should raise an exception if you're attempting to add a box that exists as a V1 box" do
prev_box_name = "foo"
# Create the V1 box
environment.box1(prev_box_name)
# Attempt to add some V2 box with the same name
box_path = environment.box2_file(:vmware)
expect { instance.add(box_path, prev_box_name, :vmware) }.
to raise_error(Vagrant::Errors::BoxUpgradeRequired)
end
it "should raise an exception and not add the box if the provider doesn't match" do
box_name = "foo"
good_provider = :virtualbox