diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-11 13:14:32 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-11 13:14:32 -0700 |
commit | 8208d088a4bba794dbf5a0d5b39e1732edc2aec4 (patch) | |
tree | 66f2037f4d997f78e587d08cd9eba84e07139f75 /spec | |
parent | c6659b70deb4b1f81bc5c20ed237b7637ff20930 (diff) | |
download | chef-8208d088a4bba794dbf5a0d5b39e1732edc2aec4.tar.gz |
specs and lazying net-http client building
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/cookbook/synchronizer_spec.rb | 7 | ||||
-rw-r--r-- | spec/unit/http/basic_client_spec.rb | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index 3f5624f3b0..82876273e7 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -414,6 +414,13 @@ describe Chef::CookbookSynchronizer do and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb") end + describe "#server_api" do + it "sets keepalive to true" do + expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], keepalives: true) + synchronizer.server_api + end + end + describe "when syncing cookbooks with the server" do let(:server_api) { double("Chef::ServerAPI (mock)") } diff --git a/spec/unit/http/basic_client_spec.rb b/spec/unit/http/basic_client_spec.rb index 8cf63d4441..79fd4ec042 100644 --- a/spec/unit/http/basic_client_spec.rb +++ b/spec/unit/http/basic_client_spec.rb @@ -29,6 +29,26 @@ describe "HTTP Connection" do end end + describe "#initialize" do + it "calls .start when doing keepalives" do + basic_client = Chef::HTTP::BasicClient.new(uri, keepalives: true) + expect(basic_client).to receive(:configure_ssl) + net_http_mock = instance_double(Net::HTTP, proxy_address: nil, "proxy_port=": nil, "read_timeout=": nil, "open_timeout=": nil) + expect(net_http_mock).to receive(:start).and_return(net_http_mock) + expect(Net::HTTP).to receive(:new).and_return(net_http_mock) + expect(basic_client.http_client).to eql(net_http_mock) + end + + it "does not call .start when not doing keepalives" do + basic_client = Chef::HTTP::BasicClient.new(uri) + expect(basic_client).to receive(:configure_ssl) + net_http_mock = instance_double(Net::HTTP, proxy_address: nil, "proxy_port=": nil, "read_timeout=": nil, "open_timeout=": nil) + expect(net_http_mock).not_to receive(:start) + expect(Net::HTTP).to receive(:new).and_return(net_http_mock) + expect(basic_client.http_client).to eql(net_http_mock) + end + end + describe "#build_http_client" do it "should build an http client" do subject.build_http_client |