Sha256: 9ae4882090a9bf6d53b590bbb83a1bda891f50e3434efb6eb2f5f530e42c0bb6

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

require 'puppet/network/http'
require 'puppet/network/http/connection'

describe Puppet::Network::HTTP::NoCachePool do
  let(:site) { Puppet::Network::HTTP::Site.new('https', 'rubygems.org', 443) }
  let(:verifier) { double('verifier', :setup_connection => nil) }

  it 'yields a started connection' do
    http  = double('http', start: nil, finish: nil, started?: true)

    factory = Puppet::Network::HTTP::Factory.new
    allow(factory).to receive(:create_connection).and_return(http)
    pool = Puppet::Network::HTTP::NoCachePool.new(factory)

    expect { |b|
      pool.with_connection(site, verifier, &b)
    }.to yield_with_args(http)
  end

  it 'yields a new connection each time' do
    http1  = double('http1', start: nil, finish: nil, started?: true)
    http2  = double('http2', start: nil, finish: nil, started?: true)

    factory = Puppet::Network::HTTP::Factory.new
    allow(factory).to receive(:create_connection).and_return(http1, http2)
    pool = Puppet::Network::HTTP::NoCachePool.new(factory)

    expect { |b|
      pool.with_connection(site, verifier, &b)
    }.to yield_with_args(http1)

    expect { |b|
      pool.with_connection(site, verifier, &b)
    }.to yield_with_args(http2)
  end

  it 'has a close method' do
    Puppet::Network::HTTP::NoCachePool.new.close
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puppet-6.15.0 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.15.0-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.15.0-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.15.0-universal-darwin spec/unit/network/http/nocache_pool_spec.rb
puppet-6.14.0 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.14.0-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.14.0-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.14.0-universal-darwin spec/unit/network/http/nocache_pool_spec.rb
puppet-6.13.0 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.13.0-x86-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.13.0-x64-mingw32 spec/unit/network/http/nocache_pool_spec.rb
puppet-6.13.0-universal-darwin spec/unit/network/http/nocache_pool_spec.rb