X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fkey_spec.rb;h=ad715d6e595a1d9439bd20b9e0dfbe2897491557;hb=HEAD;hp=d1960630e89e95cc2242a4d4ce49453226e91ce4;hpb=fab23811ccfc7bd8a313f9e359111590b7f5359c;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index d196063..ad715d6 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -15,7 +15,8 @@ def default_apt_key_example(title) source: nil, server: 'keyserver.ubuntu.com', content: nil, - options: nil } + options: nil, + refresh: false } end def bunch_things_apt_key_example(title, params) @@ -47,7 +48,6 @@ describe 'apt::key' do lsbdistid: 'Debian', osfamily: 'Debian', lsbdistcodename: 'jessie', - puppetversion: Puppet.version, } end @@ -99,6 +99,21 @@ describe 'apt::key' do end end + describe 'ensure => refreshed' do + let :params do + { + ensure: 'refreshed', + } + end + + it 'contains the apt_key with refresh => true' do + is_expected.to contain_apt_key(title).with( + ensure: 'present', + refresh: true, + ) + end + end + describe 'set a bunch of things!' do let :params do { @@ -276,7 +291,7 @@ describe 'apt::key' do end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{evaluating a Resource}) end end @@ -317,7 +332,7 @@ describe 'apt::key' do end context 'with invalid ensure' do - ['foo', 'aabsent', 'absenta', 'apresent', 'presenta'].each do |param| + ['foo', 'aabsent', 'absenta', 'apresent', 'presenta', 'refresh', 'arefreshed', 'refresheda'].each do |param| let :params do { ensure: param, @@ -325,7 +340,7 @@ describe 'apt::key' do end it 'fails' do - is_expected.to raise_error(%r{for Enum\['absent', 'present'\], got}) + is_expected.to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got}) end end end @@ -364,4 +379,30 @@ describe 'apt::key' do end end end + + describe 'defaults' do + context 'when setting keyserver on the apt class' do + let :pre_condition do + 'class { "apt": + keyserver => "keyserver.example.com", + }' + end + + it 'uses default keyserver' do + is_expected.to contain_apt_key(title).with_server('keyserver.example.com') + end + end + + context 'when setting key_options on the apt class' do + let :pre_condition do + 'class { "apt": + key_options => "http-proxy=http://proxy.example.com:8080", + }' + end + + it 'uses default keyserver' do + is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080') + end + end + end end