- context 'two apt::key resources, different ensure' do
- let :pre_condition do
- "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
- end
- it 'informs the user of the impossibility' do
- expect { subject }.to raise_error(/already ensured as absent/)
- end
+ it 'contains two apt::key resource - duplicate' do
+ is_expected.to contain_apt__key('duplicate').with(id: title,
+ ensure: 'present')
+ end
+ it 'contains two apt::key resource - title' do
+ is_expected.to contain_apt__key(title).with(id: title,
+ ensure: 'present')
+ end
+
+ it 'contains only a single apt_key - duplicate' do
+ is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title))
+ end
+ it 'contains only a single apt_key - no title' do
+ is_expected.not_to contain_apt_key(title)
+ end
+ end
+
+ describe 'duplication - two apt::key resources, different ensure' do
+ let :pre_condition do
+ "class { 'apt': }
+ apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
+ end
+
+ it 'informs the user of the impossibility' do
+ is_expected.to raise_error(%r{already ensured as absent})
+ 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')