core: error earlier if adding a path that doesn't exist

This commit is contained in:
Mitchell Hashimoto 2014-03-12 20:33:12 -07:00
parent b0f8d050f0
commit 8634cc309b
3 changed files with 17 additions and 0 deletions

View File

@ -18,6 +18,7 @@ BUG FIXES:
- core: Adding a box by path in Cygwin on Windos works. [GH-3132] - core: Adding a box by path in Cygwin on Windos works. [GH-3132]
- core: PowerShell scripts work when they're in a directory with - core: PowerShell scripts work when they're in a directory with
spaces. [GH-3100] spaces. [GH-3100]
- core: If you add a box path that doesn't exist, error earlier. [GH-3091]
- guests/darwin: Fix an exception when configuring networks. [GH-3143] - guests/darwin: Fix an exception when configuring networks. [GH-3143]
- hosts/linux: Unusual sed delimiter to avoid conflicts. [GH-3167] - hosts/linux: Unusual sed delimiter to avoid conflicts. [GH-3167]
- providers/virtualbox: Make more internal interactions with VBoxManage - providers/virtualbox: Make more internal interactions with VBoxManage

View File

@ -314,6 +314,9 @@ module Vagrant
box_url = download(url, env, show_url: show_url) box_url = download(url, env, show_url: show_url)
break break
rescue Errors::DownloaderError => e rescue Errors::DownloaderError => e
# If we don't have multiple URLs, just raise the error
raise if urls.length == 1
env[:ui].error(I18n.t( env[:ui].error(I18n.t(
"vagrant.box_download_error", message: e.message)) "vagrant.box_download_error", message: e.message))
box_url = nil box_url = nil

View File

@ -164,6 +164,19 @@ describe Vagrant::Action::Builtin::BoxAdd do
to raise_error(Vagrant::Errors::BoxChecksumMismatch) to raise_error(Vagrant::Errors::BoxChecksumMismatch)
end end
it "raises an error if the box path doesn't exist" do
box_path = iso_env.box2_file(:virtualbox)
env[:box_name] = "foo"
env[:box_url] = box_path.to_s + "nope"
box_collection.should_receive(:add).never
app.should_receive(:call).never
expect { subject.call(env) }.
to raise_error(Vagrant::Errors::DownloaderError)
end
it "force adds if exists and specified" do it "force adds if exists and specified" do
box_path = iso_env.box2_file(:virtualbox) box_path = iso_env.box2_file(:virtualbox)