Some copy change for packaging to make it more generic

This commit is contained in:
Mitchell Hashimoto 2010-07-28 07:40:21 -07:00
parent b179ee6c76
commit e7ad0ab105
2 changed files with 12 additions and 2 deletions

View File

@ -25,7 +25,7 @@ module Vagrant
@env = env
return env.error!(:package_output_exists) if File.exist?(tar_path)
return env.error!(:package_requires_directory) if !@env["package.directory"]
return env.error!(:package_requires_directory) if !@env["package.directory"] || !File.directory?(@env["package.directory"])
return if !verify_included_files
compress
@ -67,7 +67,7 @@ module Vagrant
# Compress the exported file into a package
def compress
@env.logger.info "Packaging VM into #{tar_path}..."
@env.logger.info "Compressing package to #{tar_path}..."
File.open(tar_path, Platform.tar_file_options) do |tar|
Archive::Tar::Minitar::Output.open(tar) do |output|
begin

View File

@ -47,6 +47,7 @@ class PackageGeneralActionTest < Test::Unit::TestCase
context "with an instance" do
setup do
File.stubs(:exist?).returns(false)
File.stubs(:directory?).returns(true)
@instance = @klass.new(@app, @env)
@env["package.directory"] = "foo"
@ -89,6 +90,15 @@ class PackageGeneralActionTest < Test::Unit::TestCase
assert_equal :package_requires_directory, @env.error.first
end
should "halt the chain if directory doesn't exist" do
File.expects(:directory?).with(@env["package.directory"]).returns(false)
@app.expects(:call).never
@instance.call(@env)
assert @env.error?
assert_equal :package_requires_directory, @env.error.first
end
should "run cleanup if environment errors" do
seq = sequence("seq")
@instance.expects(:verify_included_files).in_sequence(seq).returns(true)