File: puppet_config_entry_spec.rb

package info (click to toggle)
puppet-module-puppet 18.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: ruby: 2,055; sh: 15; makefile: 10
file content (89 lines) | stat: -rw-r--r-- 3,378 bytes parent folder | download
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
require 'spec_helper'

describe 'puppet::config::entry' do
  on_supported_os.each do |os, facts|
    context "on #{os}" do
      let(:facts) { facts }

      let(:title) { 'foo' }

      context 'with a plain value' do
        let :pre_condition do
          "class {'puppet': }"
        end
        let :params do
          {
            :key          => 'foo',
            :value        => 'bar',
            :section      => 'main',
            :sectionorder => 1,
          }
        end
        it 'should contain the section header' do
          should contain_concat__fragment('puppet.conf_main').with_content("\n[main]")
          should contain_concat__fragment('puppet.conf_main').with_order("1_main ")
        end
        it 'should contain the section end' do
          should contain_concat__fragment('puppet.conf_main_end').with_content("\n")
          should contain_concat__fragment('puppet.conf_main_end').with_order("1_main~end")
        end
        it 'should contain the keyvalue pair' do
          should contain_concat__fragment('puppet.conf_main_foo').with_content(/^\s+foo = bar$/)
          should contain_concat__fragment('puppet.conf_main_foo').with_order("1_main_foo ")
        end
      end
      context 'with an array value' do
        let :pre_condition do
          "class {'puppet': }"
        end
        let :params do
          {
            :key          => 'foo',
            :value        => ['bar','baz'],
            :section      => 'main',
            :sectionorder => 1,
          }
        end
        it 'should contain the section header' do
          should contain_concat__fragment('puppet.conf_main').with_content("\n[main]")
          should contain_concat__fragment('puppet.conf_main').with_order("1_main ")
        end
        it 'should contain the section end' do
          should contain_concat__fragment('puppet.conf_main_end').with_content("\n")
          should contain_concat__fragment('puppet.conf_main_end').with_order("1_main~end")
        end
        it 'should contain the keyvalue pair' do
          should contain_concat__fragment('puppet.conf_main_foo').with_content(/^\s+foo = bar,baz$/)
          should contain_concat__fragment('puppet.conf_main_foo').with_order("1_main_foo ")
        end
      end
      context 'with a custom joiner' do
        let :pre_condition do
          "class {'puppet': }"
        end
        let :params do
          {
            :key          => 'foo',
            :value        => ['bar','baz'],
            :joiner       => ':',
            :section      => 'main',
            :sectionorder => 1,
          }
        end
        it 'should contain the section header' do
          should contain_concat__fragment('puppet.conf_main').with_content("\n[main]")
          should contain_concat__fragment('puppet.conf_main').with_order("1_main ")
        end
        it 'should contain the section end' do
          should contain_concat__fragment('puppet.conf_main_end').with_content("\n")
          should contain_concat__fragment('puppet.conf_main_end').with_order("1_main~end")
        end
        it 'should contain the keyvalue pair' do
          should contain_concat__fragment('puppet.conf_main_foo').with_content(/^\s+foo = bar:baz$/)
          should contain_concat__fragment('puppet.conf_main_foo').with_order("1_main_foo ")
        end
      end

    end
  end
end