check for included files before packaging
This commit is contained in:
parent
f316e0c61c
commit
3c546ef2c7
|
@ -47,5 +47,7 @@ module Vagrant
|
|||
# @vm.invoke_callback(:after_oven, "more", "than", "one", "option")
|
||||
end
|
||||
end
|
||||
|
||||
class ActionException < Exception; end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,12 @@ module Vagrant
|
|||
@temp_path = nil
|
||||
end
|
||||
|
||||
def prepare
|
||||
@include_files.each do |file|
|
||||
raise ActionException.new("#{file} does not exist") unless File.exists?(file)
|
||||
end
|
||||
end
|
||||
|
||||
def execute!
|
||||
compress
|
||||
clean
|
||||
|
|
|
@ -4,7 +4,6 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
setup do
|
||||
@wrapper_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Package, "bing", [])
|
||||
mock_config
|
||||
|
||||
@temp_path = "temp_path"
|
||||
@action.temp_path = @temp_path
|
||||
end
|
||||
|
@ -123,4 +122,23 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
assert foo.equal?(@action.temp_path)
|
||||
end
|
||||
end
|
||||
|
||||
context "preparing the action" do
|
||||
setup do
|
||||
@include_files = ['fooiest', 'booiest']
|
||||
@action = mock_action(Vagrant::Actions::VM::Package, "bing", @include_files).last
|
||||
end
|
||||
|
||||
should "check that all the include files exist" do
|
||||
@include_files.each do |file|
|
||||
File.expects(:exists?).with(file).returns(true)
|
||||
end
|
||||
@action.prepare
|
||||
end
|
||||
|
||||
should "raise an exception when an include file does not exist" do
|
||||
File.expects(:exists?).once.returns(false)
|
||||
assert_raises(Vagrant::Actions::ActionException) { @action.prepare }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue