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
|
||||||
|
|
|
@ -8,19 +8,51 @@ class PackageActionTest < Test::Unit::TestCase
|
||||||
mock_config
|
mock_config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "setup and correct working directory and export to it" do
|
context "executing" do
|
||||||
working_dir = File.join(@action.to, @action.name)
|
setup do
|
||||||
FileUtils.expects(:rm_r).with(working_dir)
|
@tar_path = "foo"
|
||||||
@action.expects(:compress)
|
|
||||||
assert_equal @action.execute!, "#{working_dir}.box"
|
@action.stubs(:compress)
|
||||||
|
@action.stubs(:clean)
|
||||||
|
@action.stubs(:tar_path).returns(@tar_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the target file and the proper extension for tar_path" do
|
should "compress and remove the working directory" do
|
||||||
assert_equal File.join(@action.to, @action.name + Vagrant.config.package.extension), @action.tar_path
|
package_seq = sequence("package_seq")
|
||||||
|
@action.expects(:compress).in_sequence(package_seq)
|
||||||
|
@action.expects(:clean).in_sequence(package_seq)
|
||||||
|
@action.execute!
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the target working dir" do
|
should "return the tar path" do
|
||||||
assert_equal File.join(@action.to, @action.name), @action.working_dir
|
assert_equal @tar_path, @action.execute!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "cleaning up" do
|
||||||
|
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