Throw an error if a box already exists when calling box.add
This commit is contained in:
parent
21acff0e79
commit
5c6ca57409
|
@ -4,5 +4,4 @@ This is a TODO file for only this branch (config-overhaul)
|
|||
* Only allow one kind of vagrantfile to be loaded (i.e. if both
|
||||
Vagrantfile and vagrantfile exist, throw an error)
|
||||
* Nicer error if can't setup home directory
|
||||
* vagrant box add should error if box already exists
|
||||
* Default name to folder name + timestamp
|
|
@ -33,6 +33,8 @@ module Vagrant
|
|||
# Adds a box to this collection with the given name and located
|
||||
# at the given URL.
|
||||
def add(name, url)
|
||||
raise Errors::BoxAlreadyExists, :name => name if find(name)
|
||||
|
||||
@action_runner.run(:box_add,
|
||||
:box_name => name,
|
||||
:box_url => url,
|
||||
|
|
|
@ -31,6 +31,11 @@ describe Vagrant::BoxCollection do
|
|||
end
|
||||
end
|
||||
|
||||
it "should throw an error if the box already exists when adding" do
|
||||
environment.box("foo")
|
||||
expect { instance.add("foo", "bar") }.to raise_error(Vagrant::Errors::BoxAlreadyExists)
|
||||
end
|
||||
|
||||
it "should add the box" do
|
||||
name = "foo"
|
||||
url = "bar"
|
||||
|
|
Loading…
Reference in New Issue