root / spec / defines / config_spec.rb @ aaa37172
Historique | Voir | Annoter | Télécharger (2,46 ko)
1 | 30462da1 | Steve Traylen | require 'spec_helper'
|
---|---|---|---|
2 | |||
3 | describe 'nftables::config' do |
||
4 | let(:pre_condition) { 'include nftables' } |
||
5 | |||
6 | on_supported_os.each do |os, facts|
|
||
7 | context "on #{os}" do |
||
8 | let(:title) { 'FOO-BAR' } |
||
9 | let(:facts) do |
||
10 | facts |
||
11 | end
|
||
12 | |||
13 | context 'with source and content both unset' do |
||
14 | it { is_expected.not_to compile } |
||
15 | end
|
||
16 | |||
17 | context 'with a non hyphenated title' do |
||
18 | let(:title) { 'STRING' } |
||
19 | |||
20 | it { is_expected.not_to compile } |
||
21 | end
|
||
22 | |||
23 | context 'with source and content both set' do |
||
24 | let(:params) do |
||
25 | { |
||
26 | source: 'foo', |
||
27 | content: 'puppet:///modules/foo/bar', |
||
28 | } |
||
29 | end
|
||
30 | |||
31 | it { |
||
32 | pending('Setting source and content should be made to fail')
|
||
33 | is_expected.not_to compile |
||
34 | } |
||
35 | end
|
||
36 | context 'with content set' do |
||
37 | let(:params) do |
||
38 | { |
||
39 | content: 'strange content', |
||
40 | } |
||
41 | end
|
||
42 | |||
43 | it { is_expected.to compile } |
||
44 | it { is_expected.to contain_concat('nftables-FOO-BAR') }
|
||
45 | it { |
||
46 | is_expected.to contain_concat('nftables-FOO-BAR').with(
|
||
47 | path: '/etc/nftables/puppet-preflight/FOO-BAR.nft', |
||
48 | ensure_newline: true, |
||
49 | mode: '0640', |
||
50 | ) |
||
51 | } |
||
52 | it { is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft') }
|
||
53 | it { |
||
54 | is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft').with(
|
||
55 | ensure: 'file', |
||
56 | source: '/etc/nftables/puppet-preflight/FOO-BAR.nft', |
||
57 | mode: '0640', |
||
58 | ) |
||
59 | } |
||
60 | it { is_expected.to contain_concat_fragment('nftables-FOO-BAR-header') }
|
||
61 | it { |
||
62 | is_expected.to contain_concat_fragment('nftables-FOO-BAR-header').with(
|
||
63 | target: 'nftables-FOO-BAR', |
||
64 | order: '00', |
||
65 | content: 'table FOO BAR {', |
||
66 | ) |
||
67 | } |
||
68 | it { |
||
69 | is_expected.to contain_concat_fragment('nftables-FOO-BAR-body').with(
|
||
70 | target: 'nftables-FOO-BAR', |
||
71 | order: '98', |
||
72 | content: 'strange content', |
||
73 | ) |
||
74 | } |
||
75 | end
|
||
76 | context 'with content set' do |
||
77 | let(:params) do |
||
78 | { |
||
79 | source: 'puppet:///modules/foo', |
||
80 | } |
||
81 | end
|
||
82 | |||
83 | it { |
||
84 | is_expected.to contain_concat_fragment('nftables-FOO-BAR-body').with(
|
||
85 | target: 'nftables-FOO-BAR', |
||
86 | order: '98', |
||
87 | source: 'puppet:///modules/foo', |
||
88 | ) |
||
89 | } |
||
90 | end
|
||
91 | end
|
||
92 | end
|
||
93 | end |