Unpackage now has its own rescue implementation
This commit is contained in:
parent
bf738d4db5
commit
20ed284372
|
@ -13,6 +13,13 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rescue(exception)
|
||||||
|
if File.directory?(box_dir)
|
||||||
|
logger.info "An error occurred, rolling back box unpackaging..."
|
||||||
|
FileUtils.rm_rf(box_dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def setup_box_dir
|
def setup_box_dir
|
||||||
if File.directory?(box_dir)
|
if File.directory?(box_dir)
|
||||||
error_and_exit(<<-msg)
|
error_and_exit(<<-msg)
|
||||||
|
|
|
@ -28,6 +28,27 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "rescuing" do
|
||||||
|
setup do
|
||||||
|
File.stubs(:directory?).returns(false)
|
||||||
|
FileUtils.stubs(:rm_rf)
|
||||||
|
|
||||||
|
@box_dir = mock("foo")
|
||||||
|
@action.stubs(:box_dir).returns(@box_dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "do nothing if a directory doesn't exist" do
|
||||||
|
FileUtils.expects(:rm_rf).never
|
||||||
|
@action.rescue(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "remove the box directory if it exists" do
|
||||||
|
File.expects(:directory?).returns(true)
|
||||||
|
FileUtils.expects(:rm_rf).with(@box_dir).once
|
||||||
|
@action.rescue(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "box directory" do
|
context "box directory" do
|
||||||
should "return the runner directory" do
|
should "return the runner directory" do
|
||||||
result = mock("object")
|
result = mock("object")
|
||||||
|
|
Loading…
Reference in New Issue