Code Review
/
puppet-modules
/
puppetlabs-apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge pull request #1024 from david22swan/GH-iac-334/main/remove_compatible_code
[puppet-modules/puppetlabs-apt.git]
/
spec
/
defines
/
setting_spec.rb
diff --git
a/spec/defines/setting_spec.rb
b/spec/defines/setting_spec.rb
index b109ea6b6b499834f0ac0a6ae7472f6f55136c2a..97ebdc4658e138da356953c454d1fbd12cf74067 100644
(file)
--- a/
spec/defines/setting_spec.rb
+++ b/
spec/defines/setting_spec.rb
@@
-1,57
+1,76
@@
+# frozen_string_literal: true
+
require 'spec_helper'
describe 'apt::setting' do
let(:pre_condition) { 'class { "apt": }' }
require 'spec_helper'
describe 'apt::setting' do
let(:pre_condition) { 'class { "apt": }' }
- let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Debian',
+ release: {
+ major: '9',
+ full: '9.0',
+ },
+ distro: {
+ codename: 'stretch',
+ id: 'Debian',
+ },
+ },
+ }
+ end
let(:title) { 'conf-teddybear' }
let(:title) { 'conf-teddybear' }
- let(:default_params) { {
:content =>
'di' } }
+ let(:default_params) { {
content:
'di' } }
describe 'when using the defaults' do
context 'without source or content' do
it do
describe 'when using the defaults' do
context 'without source or content' do
it do
-
expect { subject.call }.to raise_error(Puppet::Error, /needs either of /
)
+
is_expected.to raise_error(Puppet::Error, %r{needs either of }
)
end
end
context 'with title=conf-teddybear ' do
let(:params) { default_params }
end
end
context 'with title=conf-teddybear ' do
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }
+
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') }
end
context 'with title=pref-teddybear' do
let(:title) { 'pref-teddybear' }
let(:params) { default_params }
end
context 'with title=pref-teddybear' do
let(:title) { 'pref-teddybear' }
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Exec[apt_update]') }
+
+ it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') }
end
context 'with title=list-teddybear' do
let(:title) { 'list-teddybear' }
let(:params) { default_params }
end
context 'with title=list-teddybear' do
let(:title) { 'list-teddybear' }
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Exec[apt_update]') }
+
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') }
end
context 'with source' do
end
context 'with source' do
- let(:params) { { :source => 'puppet:///la/die/dah' } }
+ let(:params) { { source: 'puppet:///la/die/dah' } }
+
it {
it {
- is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
- :ensure => 'file',
- :owner => 'root',
- :group => 'root',
- :mode => '0644',
- :source => "#{params[:source]}",
- })}
+ is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
+ owner: 'root',
+ group: 'root',
+ source: params[:source].to_s)
+ }
end
context 'with content' do
let(:params) { default_params }
end
context 'with content' do
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
- :ensure => 'file',
-
:owner => 'root
',
-
:group =>
'root',
-
:mode => '0644
',
- :content => "#{params[:content]}",
- }
)}
+
+ it {
+
is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file
',
+
owner:
'root',
+
group: 'root
',
+ content: params[:content].to_s)
+ }
end
end
end
end
@@
-61,55
+80,74
@@
describe 'apt::setting' do
apt::setting { "list-teddybear": content => "foo" }
'
end
apt::setting { "list-teddybear": content => "foo" }
'
end
- let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
+ let(:facts) do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Debian',
+ release: {
+ major: '9',
+ full: '9.0',
+ },
+ distro: {
+ codename: 'stretch',
+ id: 'Debian',
+ },
+ },
+ }
+ end
let(:title) { 'conf-teddybear' }
let(:title) { 'conf-teddybear' }
- let(:default_params) { {
:content =>
'di' } }
+ let(:default_params) { {
content:
'di' } }
- let(:params) { default_params.merge(
{ :require => 'Apt::Setting[list-teddybear]' }
) }
+ let(:params) { default_params.merge(
require: 'Apt::Setting[list-teddybear]'
) }
it { is_expected.to compile.with_all_deps }
end
describe 'when trying to pull one over' do
context 'with source and content' do
it { is_expected.to compile.with_all_deps }
end
describe 'when trying to pull one over' do
context 'with source and content' do
- let(:params) { default_params.merge({ :source => 'la' }) }
+ let(:params) { default_params.merge(source: 'la') }
+
it do
it do
-
expect { subject.call }.to raise_error(Puppet::Error, /cannot have both /
)
+
is_expected.to raise_error(Puppet::Error, %r{cannot have both }
)
end
end
context 'with title=ext-teddybear' do
let(:title) { 'ext-teddybear' }
let(:params) { default_params }
end
end
context 'with title=ext-teddybear' do
let(:title) { 'ext-teddybear' }
let(:params) { default_params }
+
it do
it do
-
expect { subject.call }.to raise_error(Puppet::Error, /must start with /
)
+
is_expected.to raise_error(Puppet::Error, %r{must start with either}
)
end
end
context 'with ensure=banana' do
end
end
context 'with ensure=banana' do
- let(:params) { default_params.merge({ :ensure => 'banana' }) }
+ let(:params) { default_params.merge(ensure: 'banana') }
+
it do
it do
-
expect { subject.call }.to raise_error(Puppet::Error, /"banana" does not /
)
+
is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]}
)
end
end
context 'with priority=1.2' do
end
end
context 'with priority=1.2' do
- let(:params) { default_params.merge({ :priority => 1.2 }) }
- it do
- expect { subject.call }.to raise_error(Puppet::Error, /be an integer /)
- end
+ let(:params) { default_params.merge(priority: 1.2) }
+
+ it { is_expected.to compile.and_raise_error(%r{expects a value of type}) }
end
end
describe 'with priority=100' do
end
end
describe 'with priority=100' do
- let(:params) { default_params.merge({ :priority => 100 }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') }
+ let(:params) { default_params.merge(priority: 100) }
+
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') }
end
describe 'with ensure=absent' do
end
describe 'with ensure=absent' do
- let(:params) { default_params.merge({ :ensure => 'absent' }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
- :ensure => 'absent',
- })}
+ let(:params) { default_params.merge(ensure: 'absent') }
+
+ it {
+ is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
+ }
end
end
end
end