Debian Codegraph @

spec/defines/defaults_spec.rb

raw
1 # frozen_string_literal: true
2
3 require 'spec_helper'
4
5 describe 'haproxy::defaults' do
6 let :pre_condition do
7 'class{"haproxy":
8 config_file => "/tmp/haproxy.cfg"
9 }
10 '
11 end
12 let(:title) { 'test' }
13 let(:facts) do
14 {
15 networking: {
16 ip: '1.1.1.1'
17 },
18 os: {
19 family: 'RedHat'
20 },
21 concat_basedir: '/dne'
22 }
23 end
24
25 context 'with a single option' do
26 let(:params) do
27 {
28 options: { 'balance' => 'roundrobin' },
29 merge_options: false
30 }
31 end
32
33 it {
34 is_expected.to contain_concat__fragment('haproxy-test_defaults_block').with(
35 'order' => '25-test',
36 'target' => '/tmp/haproxy.cfg',
37 'content' => "\n\ndefaults test\n balance roundrobin\n",
38 )
39 }
40 end
41
42 context 'with merge defaults true' do
43 let(:params) do
44 {
45 options: { 'balance' => 'roundrobin' }
46 }
47 end
48
49 defaults_output = <<~EXPECTEDOUTPUT
50
51
52 defaults test
53 balance roundrobin
54 log global
55 maxconn 8000
56 option redispatch
57 retries 3
58 timeout http-request 10s
59 timeout queue 1m
60 timeout connect 10s
61 timeout client 1m
62 timeout server 1m
63 timeout check 10s
64 EXPECTEDOUTPUT
65 it {
66 is_expected.to contain_concat__fragment('haproxy-test_defaults_block').with(
67 'order' => '25-test',
68 'target' => '/tmp/haproxy.cfg',
69 'content' => defaults_output,
70 )
71 }
72 end
73 end