summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook/synchronizer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/cookbook/synchronizer_spec.rb')
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb50
1 files changed, 26 insertions, 24 deletions
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 0762a11771..a1d312836b 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -217,6 +217,8 @@ describe Chef::CookbookSynchronizer do
path: "/tmp/cookbook_a_template_default_tempfile")
end
+ let(:root) { windows? ? "C:/file-cache/cookbooks/cookbook_a" : "/file-cache/cookbooks/cookbook_a" }
+
def setup_common_files_missing_expectations
# Files are not in the cache:
expect(file_cache).to receive(:key?)
@@ -234,7 +236,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request)
@@ -244,7 +246,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_missing_expectations
@@ -262,7 +264,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
expect(server_api).to receive(:streaming_request)
.with("http://chef.example.com/ffffff")
@@ -271,7 +273,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
end
def setup_common_files_chksum_mismatch_expectations
@@ -292,11 +294,11 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
# Current file has fff000, want abc123
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .with("#{root}/recipes/default.rb")
.and_return("fff000").at_least(:once)
# Fetch and copy default.rb attribute file
@@ -308,11 +310,11 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
# Current file has fff000, want abc456
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .with("#{root}/attributes/default.rb")
.and_return("fff000").at_least(:once)
end
@@ -334,7 +336,7 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
# Fetch and copy apache2.conf template
expect(server_api).to receive(:streaming_request)
@@ -345,16 +347,16 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
# Current file has fff000
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .with("#{root}/default/megaman.conf")
.and_return("fff000")
# Current file has fff000
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .with("#{root}/templates/default/apache2.conf.erb")
.and_return("fff000")
end
@@ -369,23 +371,23 @@ describe Chef::CookbookSynchronizer do
# Current file has abc123, want abc123
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .with("#{root}/recipes/default.rb")
.and_return("abc123").at_least(:once)
# Current file has abc456, want abc456
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .with("#{root}/attributes/default.rb")
.and_return("abc456").at_least(:once)
# :load called twice
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_present_expectations
@@ -399,23 +401,23 @@ describe Chef::CookbookSynchronizer do
# Current file has abc124, want abc124
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .with("#{root}/default/megaman.conf")
.and_return("abc124")
# Current file has abc125, want abc125
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .with("#{root}/templates/default/apache2.conf.erb")
.and_return("abc125")
# :load called twice
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
end
describe "#server_api" do
@@ -535,19 +537,19 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/files/default/megaman.conf")
+ .and_return("#{root}/files/default/megaman.conf")
expect(Chef::Log).to receive(:warn)
.with("skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!")
.once