+# frozen_string_literal: true
+
require 'spec_helper'
describe 'apt::setting' do
let(:pre_condition) { 'class { "apt": }' }
let :facts do
{
- os: { distro: { codename: 'wheezy' }, family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
- lsbdistrelease: '7.0',
- lsbdistcodename: 'wheezy',
- operatingsystem: 'Debian',
- osfamily: 'Debian',
- lsbdistid: 'Debian',
- puppetversion: Puppet.version,
+ os: {
+ family: 'Debian',
+ name: 'Debian',
+ release: {
+ major: '9',
+ full: '9.0',
+ },
+ distro: {
+ codename: 'stretch',
+ id: 'Debian',
+ },
+ },
}
end
let(:title) { 'conf-teddybear' }
describe 'when using the defaults' do
context 'without source or content' do
it do
- expect { subject.call }.to raise_error(Puppet::Error, %r{needs either of })
+ is_expected.to raise_error(Puppet::Error, %r{needs either of })
end
end
is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
owner: 'root',
group: 'root',
- mode: '0644',
source: params[:source].to_s)
}
end
is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
owner: 'root',
group: 'root',
- mode: '0644',
content: params[:content].to_s)
}
end
end
let(:facts) do
{
- os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
- lsbdistid: 'Debian',
- osfamily: 'Debian',
- lsbdistcodename: 'wheezy',
- puppetversion: Puppet.version,
+ os: {
+ family: 'Debian',
+ name: 'Debian',
+ release: {
+ major: '9',
+ full: '9.0',
+ },
+ distro: {
+ codename: 'stretch',
+ id: 'Debian',
+ },
+ },
}
end
let(:title) { 'conf-teddybear' }
let(:params) { default_params.merge(source: 'la') }
it do
- expect { subject.call }.to raise_error(Puppet::Error, %r{cannot have both })
+ is_expected.to raise_error(Puppet::Error, %r{cannot have both })
end
end
let(:params) { default_params }
it do
- expect { subject.call }.to raise_error(Puppet::Error, %r{must start with either})
+ is_expected.to raise_error(Puppet::Error, %r{must start with either})
end
end
let(:params) { default_params.merge(ensure: 'banana') }
it do
- expect { subject.call }.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
+ is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
end
end
context 'with priority=1.2' do
let(:params) { default_params.merge(priority: 1.2) }
- if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') >= 0 || ENV['FUTURE_PARSER'] == 'yes'
- it { is_expected.to compile.and_raise_error(%r{expects a value of type}) }
- else
- it { is_expected.to compile.and_raise_error(%r{priority must be an integer or a zero-padded integer}) }
- end
+ it { is_expected.to compile.and_raise_error(%r{expects a value of type}) }
end
end