1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
# frozen_string_literal: true
require 'spec_helper'
describe 'postfix::conffile' do
let(:title) { 'foo' }
let :pre_condition do
"class { 'postfix': }"
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context 'when passing wrong value for ensure' do
let(:params) do
{
ensure: 'running',
}
end
it 'fails' do
expect do
is_expected.to contain_file('postfix conffile foo')
end.to raise_error(Puppet::Error, %r{got 'running'})
end
end
context 'when passing both source and content' do
let(:params) do
{
source: '/tmp/bar',
content: 'bar',
}
end
it 'fails' do
expect do
is_expected.to contain_file('postfix conffile foo')
end.to raise_error(Puppet::Error, %r{You must provide either 'source' or 'content'})
end
end
context 'when passing source' do
let(:params) do
{
source: 'puppet:///modules/postfix/bar',
}
end
it {
is_expected.to contain_file('postfix conffile foo').with(
ensure: 'present',
source: 'puppet:///modules/postfix/bar'
).without(:content)
}
end
context 'when passing content' do
let(:params) do
{
content: 'bar',
}
end
it {
is_expected.to contain_file('postfix conffile foo').with(
ensure: 'present',
content: 'bar'
).without(:source)
}
end
context 'when not passing source or content' do
it 'fails' do
expect do
is_expected.to contain_file('postfix conffile foo')
end.to raise_error(Puppet::Error, %r{You must provide 'options' hash parameter if you don't provide 'source' neither 'content'})
end
end
# context 'when passing options parameter' do
# let(:params) { {
# :options => {
# :server_host => 'ldap.mydomain.com',
# :bind => 'no',
# },
# } }
# it { is_expected.to contain_file('postfix conffile foo').with(
# :ensure => 'present',
# :content => '#
######################################################
## File managed by puppet
## DO NOT EDITY!!!
##
# bind = no
# server_host = ldap.mydomain.com'
# ).without(:source)
# }
# end
context 'when ensuring absence' do
let(:params) do
{
ensure: 'absent',
}
end
it { is_expected.to contain_file('postfix conffile foo').with_ensure('absent') }
end
context 'when using mode' do
let(:params) do
{
mode: '0644',
content: 'bar',
}
end
it {
is_expected.to contain_file('postfix conffile foo').with(
mode: '0644',
content: 'bar'
)
}
end
context 'when using path' do
let(:params) do
{
path: '/tmp/foo',
content: 'bar',
}
end
it {
is_expected.to contain_file('postfix conffile foo').with(
path: '/tmp/foo',
content: 'bar'
)
}
end
end
end
end
|