Box verification actually raises error to undo box adding

This commit is contained in:
Mitchell Hashimoto 2010-04-19 15:45:52 -07:00
parent 3e36b4ce12
commit 376cd2f24d
3 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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