diff options
author | Thom May <thom@chef.io> | 2015-12-02 12:19:33 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-11 15:40:42 +0000 |
commit | d99e306a41b1402209d320cb7119b12a3bbb962f (patch) | |
tree | f65940702826deb991e6198967d3e9e96cb2857a /spec/unit/cookbook | |
parent | 1b71aeb423b009f6d1a44215c89e9976957b47e9 (diff) | |
download | chef-d99e306a41b1402209d320cb7119b12a3bbb962f.tar.gz |
Convert all uses of Chef::REST to Chef::ServerAPItm/no_more_rest
In the process, stop auto-expanding JSON in the HTTP client, and let
individual classes control that themselves.
Fixes #2737, Fixes #3518
Diffstat (limited to 'spec/unit/cookbook')
-rw-r--r-- | spec/unit/cookbook/file_vendor_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/cookbook/synchronizer_spec.rb | 43 |
2 files changed, 22 insertions, 23 deletions
diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb index 145541a63f..8bf2d3c2a3 100644 --- a/spec/unit/cookbook/file_vendor_spec.rb +++ b/spec/unit/cookbook/file_vendor_spec.rb @@ -23,7 +23,7 @@ describe Chef::Cookbook::FileVendor do context "when configured to fetch files over http" do - let(:http) { double("Chef::REST") } + let(:http) { double("Chef::ServerAPI") } before do file_vendor_class.fetch_from_remote(http) diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index 2b040f3c95..30ddaad1d7 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -38,7 +38,6 @@ describe Chef::CookbookCacheCleaner do unused_template_files.each do |cbf| expect(file_cache).to receive(:delete).with(cbf) end - cookbook_hash = {"valid1"=> {}, "valid2" => {}} allow(cleaner).to receive(:cache).and_return(file_cache) cleaner.cleanup_file_cache end @@ -224,8 +223,8 @@ describe Chef::CookbookSynchronizer do and_return(false) # Fetch and copy default.rb recipe - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/abc123', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/abc123'). and_return(cookbook_a_default_recipe_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb") @@ -234,8 +233,8 @@ describe Chef::CookbookSynchronizer do and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb") # Fetch and copy default.rb attribute file - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/abc456', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/abc456'). and_return(cookbook_a_default_attribute_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb") @@ -252,8 +251,8 @@ describe Chef::CookbookSynchronizer do with("cookbooks/cookbook_a/templates/default/apache2.conf.erb"). and_return(false) - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/megaman.conf', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/megaman.conf'). and_return(cookbook_a_file_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf") @@ -261,8 +260,8 @@ describe Chef::CookbookSynchronizer do with("cookbooks/cookbook_a/files/default/megaman.conf", false). and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf") - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/ffffff', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/ffffff'). and_return(cookbook_a_template_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb") @@ -281,8 +280,8 @@ describe Chef::CookbookSynchronizer do and_return(true) # Fetch and copy default.rb recipe - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/abc123', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/abc123'). and_return(cookbook_a_default_recipe_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb") @@ -297,8 +296,8 @@ describe Chef::CookbookSynchronizer do and_return("fff000") # Fetch and copy default.rb attribute file - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/abc456', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/abc456'). and_return(cookbook_a_default_attribute_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb") @@ -323,8 +322,8 @@ describe Chef::CookbookSynchronizer do and_return(true) # Fetch and copy megaman.conf - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/megaman.conf', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/megaman.conf'). and_return(cookbook_a_file_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf") @@ -334,8 +333,8 @@ describe Chef::CookbookSynchronizer do and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf") # Fetch and copy apache2.conf template - expect(server_api).to receive(:get_rest). - with('http://chef.example.com/ffffff', true). + expect(server_api).to receive(:streaming_request). + with('http://chef.example.com/ffffff'). and_return(cookbook_a_template_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb") @@ -416,7 +415,7 @@ describe Chef::CookbookSynchronizer do end describe "when syncing cookbooks with the server" do - let(:server_api) { double("Chef::REST (mock)") } + let(:server_api) { double("Chef::ServerAPI (mock)") } let(:file_cache) { double("Chef::FileCache (mock)") } @@ -442,8 +441,8 @@ describe Chef::CookbookSynchronizer do it "does not fetch templates or cookbook files" do # Implicitly tested in previous test; this test is just for behavior specification. - expect(server_api).not_to receive(:get_rest). - with('http://chef.example.com/ffffff', true) + expect(server_api).not_to receive(:streaming_request). + with('http://chef.example.com/ffffff') synchronizer.sync_cookbooks end @@ -502,7 +501,7 @@ describe Chef::CookbookSynchronizer do it "does not update files" do expect(file_cache).not_to receive(:move_to) - expect(server_api).not_to receive(:get_rest) + expect(server_api).not_to receive(:streaming_request) synchronizer.sync_cookbooks end end @@ -512,7 +511,7 @@ describe Chef::CookbookSynchronizer do it "does not update files" do expect(file_cache).not_to receive(:move_to) - expect(server_api).not_to receive(:get_rest) + expect(server_api).not_to receive(:streaming_request) synchronizer.sync_cookbooks end end |