Package tests updated to not hit the filesystem
This commit is contained in:
parent
25f5b0bcad
commit
d447f9e377
|
@ -14,11 +14,15 @@ module Vagrant
|
||||||
compress
|
compress
|
||||||
|
|
||||||
logger.info "Removing working directory ..."
|
logger.info "Removing working directory ..."
|
||||||
FileUtils.rm_r(working_dir)
|
clean
|
||||||
|
|
||||||
tar_path
|
tar_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clean
|
||||||
|
FileUtils.rm_r(working_dir)
|
||||||
|
end
|
||||||
|
|
||||||
def working_dir
|
def working_dir
|
||||||
FileUtils.mkpath(File.join(@to, @name))
|
FileUtils.mkpath(File.join(@to, @name))
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,21 +6,53 @@ class PackageActionTest < Test::Unit::TestCase
|
||||||
@action.to = '/foo/bar/baz'
|
@action.to = '/foo/bar/baz'
|
||||||
@action.name = 'bing'
|
@action.name = 'bing'
|
||||||
mock_config
|
mock_config
|
||||||
end
|
|
||||||
|
|
||||||
should "setup and correct working directory and export to it" do
|
|
||||||
working_dir = File.join(@action.to, @action.name)
|
|
||||||
FileUtils.expects(:rm_r).with(working_dir)
|
|
||||||
@action.expects(:compress)
|
|
||||||
assert_equal @action.execute!, "#{working_dir}.box"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the target file and the proper extension for tar_path" do
|
context "executing" do
|
||||||
assert_equal File.join(@action.to, @action.name + Vagrant.config.package.extension), @action.tar_path
|
setup do
|
||||||
|
@tar_path = "foo"
|
||||||
|
|
||||||
|
@action.stubs(:compress)
|
||||||
|
@action.stubs(:clean)
|
||||||
|
@action.stubs(:tar_path).returns(@tar_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "compress and remove the working directory" do
|
||||||
|
package_seq = sequence("package_seq")
|
||||||
|
@action.expects(:compress).in_sequence(package_seq)
|
||||||
|
@action.expects(:clean).in_sequence(package_seq)
|
||||||
|
@action.execute!
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return the tar path" do
|
||||||
|
assert_equal @tar_path, @action.execute!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the target working dir" do
|
context "cleaning up" do
|
||||||
assert_equal File.join(@action.to, @action.name), @action.working_dir
|
setup do
|
||||||
|
@working_dir = "foo"
|
||||||
|
@action.stubs(:working_dir).returns(@working_dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "remove the working directory" do
|
||||||
|
FileUtils.expects(:rm_r).with(@working_dir).once
|
||||||
|
@action.clean
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "working directory" do
|
||||||
|
should "create the directory" do
|
||||||
|
FileUtils.expects(:mkpath).with(File.join(@action.to, @action.name))
|
||||||
|
@action.working_dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "tar path" do
|
||||||
|
should "be the working directory with the extension attached" do
|
||||||
|
@action.expects(:working_dir).returns("foo")
|
||||||
|
assert_equal "foo#{Vagrant.config.package.extension}", @action.tar_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO test compression once its finished
|
# TODO test compression once its finished
|
||||||
|
|
Loading…
Reference in New Issue