moved unpackage to warden

This commit is contained in:
John Bender 2010-08-22 00:49:54 -07:00
parent 30a84c6e50
commit 220fff0c19
2 changed files with 3 additions and 18 deletions

View File

@ -25,11 +25,9 @@ module Vagrant
decompress decompress
@app.call(@env) @app.call(@env)
cleanup if @env.error?
end end
def cleanup def recover(env)
if File.directory?(box_directory) if File.directory?(box_directory)
FileUtils.rm_rf(box_directory) FileUtils.rm_rf(box_directory)
end end

View File

@ -21,7 +21,6 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
@instance.expects(:setup_box_directory).in_sequence(seq).returns(true) @instance.expects(:setup_box_directory).in_sequence(seq).returns(true)
@instance.expects(:decompress).in_sequence(seq) @instance.expects(:decompress).in_sequence(seq)
@app.expects(:call).with(@env) @app.expects(:call).with(@env)
@instance.expects(:cleanup).never
@instance.call(@env) @instance.call(@env)
end end
@ -29,18 +28,6 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
@instance.expects(:setup_box_directory).returns(false) @instance.expects(:setup_box_directory).returns(false)
@instance.expects(:decompress).never @instance.expects(:decompress).never
@app.expects(:call).never @app.expects(:call).never
@instance.expects(:cleanup).never
@instance.call(@env)
end
should "cleanup if there was an error" do
@env.error!(:foo)
seq = sequence("sequence")
@instance.expects(:setup_box_directory).in_sequence(seq).returns(true)
@instance.expects(:decompress).in_sequence(seq)
@app.expects(:call).with(@env)
@instance.expects(:cleanup).once
@instance.call(@env) @instance.call(@env)
end end
end end
@ -54,13 +41,13 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
should "do nothing if not a directory" do should "do nothing if not a directory" do
FileUtils.expects(:rm_rf).never FileUtils.expects(:rm_rf).never
@instance.cleanup @instance.recover(nil)
end end
should "remove the directory if exists" do should "remove the directory if exists" do
File.expects(:directory?).with(@instance.box_directory).once.returns(true) File.expects(:directory?).with(@instance.box_directory).once.returns(true)
FileUtils.expects(:rm_rf).with(@instance.box_directory).once FileUtils.expects(:rm_rf).with(@instance.box_directory).once
@instance.cleanup @instance.recover(nil)
end end
end end