| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper' |
| 4 |
|
| 5 |
describe 'haproxy::mapfile' do |
| 6 |
let(:pre_condition) { 'include haproxy' } |
| 7 |
let(:title) { 'domains-to-backends' } |
| 8 |
let(:facts) do |
| 9 |
{ |
| 10 |
networking: { |
| 11 |
ip: '1.1.1.1' |
| 12 |
}, |
| 13 |
os: { |
| 14 |
family: 'Redhat' |
| 15 |
}, |
| 16 |
concat_basedir: '/dne' |
| 17 |
} |
| 18 |
end |
| 19 |
|
| 20 |
context 'when map domains to backends' do |
| 21 |
let(:params) do |
| 22 |
{ |
| 23 |
ensure: 'present', |
| 24 |
mappings: [ |
| 25 |
{ 'app01.example.com' => 'bk_app01' }, |
| 26 |
{ 'app02.example.com' => 'bk_app02' }, |
| 27 |
{ 'app03.example.com' => 'bk_app03' }, |
| 28 |
{ 'app04.example.com' => 'bk_app04' }, |
| 29 |
'app05.example.com bk_app05', |
| 30 |
'app06.example.com bk_app06', |
| 31 |
], |
| 32 |
instances: ['haproxy'] |
| 33 |
} |
| 34 |
end |
| 35 |
|
| 36 |
it { is_expected.to compile.with_all_deps } |
| 37 |
it { is_expected.to contain_concat('haproxy_mapfile_domains-to-backends').that_notifies('Haproxy::Service[haproxy]') } |
| 38 |
|
| 39 |
it { |
| 40 |
is_expected.to contain_concat('haproxy_mapfile_domains-to-backends').with( |
| 41 |
'path' => '/etc/haproxy/domains-to-backends.map', |
| 42 |
'ensure' => 'present', |
| 43 |
) |
| 44 |
} |
| 45 |
|
| 46 |
it { |
| 47 |
is_expected.to contain_concat__fragment('haproxy_mapfile_domains-to-backends-top').with( |
| 48 |
'order' => '00', |
| 49 |
'target' => '/etc/haproxy/domains-to-backends.map', |
| 50 |
'content' => "app01.example.com bk_app01\napp02.example.com bk_app02\napp03.example.com bk_app03\napp04.example.com bk_app04\napp05.example.com bk_app05\napp06.example.com bk_app06\n", |
| 51 |
) |
| 52 |
} |
| 53 |
end |
| 54 |
|
| 55 |
context 'when collect domains to backends' do |
| 56 |
let(:params) do |
| 57 |
{ |
| 58 |
ensure: 'present', |
| 59 |
instances: ['haproxy'] |
| 60 |
} |
| 61 |
end |
| 62 |
|
| 63 |
it { is_expected.to compile.with_all_deps } |
| 64 |
|
| 65 |
it { |
| 66 |
is_expected.to contain_concat__fragment('haproxy_mapfile_domains-to-backends-top').with( |
| 67 |
'order' => '00', |
| 68 |
'target' => '/etc/haproxy/domains-to-backends.map', |
| 69 |
'content' => '', |
| 70 |
) |
| 71 |
} |
| 72 |
end |
| 73 |
end |