action general package moved to warden cleanup

This commit is contained in:
John Bender 2010-07-30 18:27:02 -07:00
parent c0121ac08e
commit 0c011e80c7
2 changed files with 3 additions and 18 deletions

View File

@ -30,11 +30,9 @@ module Vagrant
compress compress
@app.call(env) @app.call(env)
cleanup if env.error?
end end
def cleanup def rescue(env)
# Cleanup any packaged files if the packaging failed at some point. # Cleanup any packaged files if the packaging failed at some point.
File.delete(tar_path) if File.exist?(tar_path) File.delete(tar_path) if File.exist?(tar_path)
end end

View File

@ -59,8 +59,6 @@ class PackageGeneralActionTest < Test::Unit::TestCase
@instance.expects(:verify_included_files).in_sequence(seq).returns(true) @instance.expects(:verify_included_files).in_sequence(seq).returns(true)
@instance.expects(:compress).in_sequence(seq) @instance.expects(:compress).in_sequence(seq)
@app.expects(:call).with(@env).in_sequence(seq) @app.expects(:call).with(@env).in_sequence(seq)
@instance.expects(:cleanup).never
@instance.call(@env) @instance.call(@env)
end end
@ -98,17 +96,6 @@ class PackageGeneralActionTest < Test::Unit::TestCase
assert @env.error? assert @env.error?
assert_equal :package_requires_directory, @env.error.first assert_equal :package_requires_directory, @env.error.first
end end
should "run cleanup if environment errors" do
seq = sequence("seq")
@instance.expects(:verify_included_files).in_sequence(seq).returns(true)
@instance.expects(:compress).in_sequence(seq)
@app.expects(:call).with(@env).in_sequence(seq)
@instance.expects(:cleanup).in_sequence(seq)
@env.error!(:foo)
@instance.call(@env)
end
end end
context "cleaning up" do context "cleaning up" do
@ -123,14 +110,14 @@ class PackageGeneralActionTest < Test::Unit::TestCase
File.expects(:exist?).with(@instance.tar_path).returns(false) File.expects(:exist?).with(@instance.tar_path).returns(false)
File.expects(:delete).never File.expects(:delete).never
@instance.cleanup @instance.rescue(@env)
end end
should "delete the packaged box if it exists" do should "delete the packaged box if it exists" do
File.expects(:exist?).returns(true) File.expects(:exist?).returns(true)
File.expects(:delete).with(@instance.tar_path).once File.expects(:delete).with(@instance.tar_path).once
@instance.cleanup @instance.rescue(@env)
end end
end end