Package tests updated to not hit the filesystem
This commit is contained in:
parent
25f5b0bcad
commit
d447f9e377
|
@ -14,11 +14,15 @@ module Vagrant
|
|||
compress
|
||||
|
||||
logger.info "Removing working directory ..."
|
||||
FileUtils.rm_r(working_dir)
|
||||
clean
|
||||
|
||||
tar_path
|
||||
end
|
||||
|
||||
def clean
|
||||
FileUtils.rm_r(working_dir)
|
||||
end
|
||||
|
||||
def working_dir
|
||||
FileUtils.mkpath(File.join(@to, @name))
|
||||
end
|
||||
|
|
|
@ -8,19 +8,51 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
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"
|
||||
context "executing" do
|
||||
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
|
||||
|
||||
should "return the target file and the proper extension for tar_path" do
|
||||
assert_equal File.join(@action.to, @action.name + Vagrant.config.package.extension), @action.tar_path
|
||||
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
|
||||
|
||||
should "return the target working dir" do
|
||||
assert_equal File.join(@action.to, @action.name), @action.working_dir
|
||||
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
|
||||
|
||||
# TODO test compression once its finished
|
||||
|
|
Loading…
Reference in New Issue