Project

General

Profile

« Previous | Next » 

Revision 935d45ab

Added by Ewoud Kohl van Wijngaarden about 4 years ago

Introduce foreman_proxy::globals

This class is intended to allow overriding some parameters that
basically never change. This makes the parameters of init.pp slightly
easier to digest. It also allows testing of some modules by just
including params without the entire foreman_proxy class. This makes
tests faster but also more focused.

View differences:

spec/defines/foreman_proxy_settings_file_spec.rb
'foreman-proxy', 'settings.d', "#{title}.yml"
)
end
let(:pre_condition) { 'include foreman_proxy' }
context 'defaults, module enabled' do
it do
is_expected.to contain_file(config_path).with(
ensure: 'file',
owner: 'root',
group: ['FreeBSD', 'DragonFly'].include?(facts[:osfamily]) ? 'foreman_proxy' : 'foreman-proxy',
mode: '0640',
)
context 'standalone' do
let(:pre_condition) { 'include foreman_proxy::params' }
context 'defaults, module enabled' do
it do
is_expected.to contain_file(config_path).with(
ensure: 'file',
owner: 'root',
group: ['FreeBSD', 'DragonFly'].include?(facts[:osfamily]) ? 'foreman_proxy' : 'foreman-proxy',
mode: '0640',
)
end
it 'should set :enabled in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: https'])
end
it { is_expected.not_to contain_foreman_proxy__feature('Test') }
end
it { is_expected.to contain_file(config_path).that_requires('Class[foreman_proxy::install]') }
it { is_expected.to contain_file(config_path).that_notifies('Class[foreman_proxy::service]') }
it 'should set :enabled in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: https'])
context 'with feature' do
let(:params) { { feature: 'Test' } }
it { is_expected.to contain_foreman_proxy__feature('Test') }
end
it { is_expected.not_to contain_foreman_proxy__feature('Test') }
end
context 'with listen_on => both' do
let(:params) { { listen_on: 'both' } }
context 'with feature' do
let(:params) { { feature: 'Test' } }
it { is_expected.to contain_foreman_proxy__feature('Test') }
end
it 'should set :enabled to true in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: true'])
end
end
context 'with listen_on => both' do
let(:params) { { listen_on: 'both' } }
context 'with listen_on => http' do
let(:params) { { listen_on: 'http' } }
it 'should set :enabled to true in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: true'])
it 'should set :enabled to http in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: http'])
end
end
end
context 'with listen_on => http' do
let(:params) { { listen_on: 'http' } }
context 'with enabled => false' do
let(:params) { { enabled: false } }
it 'should set :enabled to false in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: false'])
end
it 'should set :enabled to http in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: http'])
context 'with feature' do
let(:params) { { enabled: false, feature: 'Test' } }
it { is_expected.not_to contain_foreman_proxy__feature('Test') }
end
end
end
context 'with enabled => false' do
let(:params) { { enabled: false } }
it 'should set :enabled to false in config' do
verify_exact_contents(catalogue, config_path, ['---', ':enabled: false'])
end
context 'with foreman_proxy included' do
let(:pre_condition) { 'include foreman_proxy' }
context 'with feature' do
let(:params) { { enabled: false, feature: 'Test' } }
it { is_expected.not_to contain_foreman_proxy__feature('Test') }
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file(config_path).that_requires('Class[foreman_proxy::install]').that_notifies('Class[foreman_proxy::service]') }
end
end
end

Also available in: Unified diff