From 376cd2f24d530987f6d3efaff60da19e9b302bec Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 19 Apr 2010 15:45:52 -0700 Subject: [PATCH] Box verification actually raises error to undo box adding --- lib/vagrant/actions/box/verify.rb | 3 +-- templates/errors.yml | 3 +++ test/vagrant/actions/box/verify_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/actions/box/verify.rb b/lib/vagrant/actions/box/verify.rb index 9838994be..22adde14a 100644 --- a/lib/vagrant/actions/box/verify.rb +++ b/lib/vagrant/actions/box/verify.rb @@ -23,9 +23,8 @@ module Vagrant def verify_appliance # We now try to read the applince. If it succeeds, we return true. VirtualBox::Appliance.new(@runner.ovf_file) - true rescue VirtualBox::Exceptions::FileErrorException - false + raise ActionException.new(:box_verification_failed) end end end diff --git a/templates/errors.yml b/templates/errors.yml index cd9417089..c12d23260 100644 --- a/templates/errors.yml +++ b/templates/errors.yml @@ -17,6 +17,9 @@ The box must be added through the `vagrant box add` command. Please view the documentation associated with the command for more information. +:box_verification_failed: |- + The specified box is invalid. This can commonly be attributed to incorrectly + typing in the path to the box or invalid packaging of the box. :box_not_specified: |- No base box was specified! A base box is required as a staring point for every vagrant virtual machine. Please specify one in your Vagrantfile diff --git a/test/vagrant/actions/box/verify_test.rb b/test/vagrant/actions/box/verify_test.rb index 1350ad240..7e5c6ee9d 100644 --- a/test/vagrant/actions/box/verify_test.rb +++ b/test/vagrant/actions/box/verify_test.rb @@ -33,12 +33,12 @@ class VerifyBoxActionTest < Test::Unit::TestCase should "create new appliance and return true if succeeds" do VirtualBox::Appliance.expects(:new).with(@runner.ovf_file) - assert @action.verify_appliance + assert_nothing_raised { @action.verify_appliance } end should "return false if an exception is raised" do VirtualBox::Appliance.expects(:new).with(@runner.ovf_file).raises(VirtualBox::Exceptions::FileErrorException) - assert !@action.verify_appliance + assert_raises(Vagrant::Actions::ActionException) { @action.verify_appliance } end end end