provisioners/chef: fix failing tests

This commit is contained in:
Mitchell Hashimoto 2015-01-06 10:56:28 -08:00
parent de6b55d007
commit 5b4b387f04
4 changed files with 9 additions and 10 deletions

View File

@ -24,11 +24,7 @@ module VagrantPlugins
super
@recipe = nil if @recipe == UNSET_VALUE
if @upload_path == UNSET_VALUE
counter = self.class.get_and_update_counter(:chef_apply)
@upload_path = "/tmp/vagrant-chef-apply-#{counter}"
end
@upload_path = "/tmp/vagrant-chef-apply" if @upload_path == UNSET_VALUE
end
def validate(machine)

View File

@ -1,3 +1,4 @@
require "digest/md5"
require "tempfile"
require_relative "base"
@ -41,8 +42,8 @@ module VagrantPlugins
# The destination (on the guest) where the recipe will live
# @return [String]
def target_recipe_path
File.join(config.upload_path, "recipe.rb")
def target_recipe_path(key)
File.join(config.upload_path, "recipe-#{key}.rb")
end
# Write the raw recipe contents to a tempfile and upload that to the
@ -54,7 +55,9 @@ module VagrantPlugins
file.rewind
# Upload the tempfile to the guest
@machine.communicate.upload(file.path, target_recipe_path)
@machine.communicate.upload(
file.path,
target_recipe_path(Digest::MD5.hexdigest(config.recipe)))
ensure
# Delete our template
file.close

View File

@ -123,7 +123,7 @@ describe VagrantPlugins::Chef::Config::BaseRunner do
describe "#provisioning_path" do
it "defaults to a tmp_path" do
subject.finalize!
expect(subject.provisioning_path).to match(%r{/tmp/vagrant-chef-\d+})
expect(subject.provisioning_path).to eq("/tmp/vagrant-chef")
end
end

View File

@ -23,7 +23,7 @@ describe VagrantPlugins::Chef::Config::ChefApply do
describe "#upload_path" do
it "defaults to /tmp/vagrant-chef-apply.rb" do
subject.finalize!
expect(subject.upload_path).to match(%r{/tmp/vagrant-chef-apply-\d+})
expect(subject.upload_path).to eq("/tmp/vagrant-chef-apply")
end
end