root / spec / defines / file_spec.rb @ 7030bde0
Historique | Voir | Annoter | Télécharger (2,69 ko)
1 |
# frozen_string_literal: true
|
---|---|
2 |
|
3 |
require 'spec_helper'
|
4 |
|
5 |
describe 'nftables::file' do |
6 |
let(:pre_condition) { 'include nftables' } |
7 |
let(:title) { 'FOO' } |
8 |
|
9 |
on_supported_os.each do |os, facts|
|
10 |
context "on #{os}" do |
11 |
let(:facts) do |
12 |
facts |
13 |
end
|
14 |
|
15 |
context 'with source and content both unset' do |
16 |
it { is_expected.to compile } |
17 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').without_source }
|
18 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').without_content }
|
19 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').without_source }
|
20 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').without_content }
|
21 |
it { is_expected.to contain_exec('nft validate') }
|
22 |
it { is_expected.to contain_service('nftables') }
|
23 |
it { is_expected.to contain_package('nftables').that_comes_before('File[/etc/nftables/puppet-preflight/file-FOO.nft]') } |
24 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').that_notifies('Exec[nft validate]') } |
25 |
it { is_expected.to contain_exec('nft validate').that_comes_before('File[/etc/nftables/puppet/file-FOO.nft]') } |
26 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').that_notifies('Service[nftables]') } |
27 |
end
|
28 |
|
29 |
context 'with source set only' do |
30 |
let(:params) do |
31 |
{ source: 'puppet:///module/foobar.nft' } |
32 |
end
|
33 |
|
34 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').without_content }
|
35 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').with_source('puppet:///module/foobar.nft') } |
36 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').without_content }
|
37 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').with_source('puppet:///module/foobar.nft') } |
38 |
end
|
39 |
|
40 |
context 'with content set only' do |
41 |
let(:params) do |
42 |
{ content: '# my rules' } |
43 |
end
|
44 |
|
45 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').without_source }
|
46 |
it { is_expected.to contain_file('/etc/nftables/puppet-preflight/file-FOO.nft').with_content('# my rules') } |
47 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').without_source }
|
48 |
it { is_expected.to contain_file('/etc/nftables/puppet/file-FOO.nft').with_content('# my rules') } |
49 |
end
|
50 |
|
51 |
context 'with content and source set' do |
52 |
let(:params) do |
53 |
{ content: '# my rules', source: 'puppet:///modules/foobar.nft' } |
54 |
end
|
55 |
|
56 |
it { is_expected.not_to compile } |
57 |
end
|
58 |
end
|
59 |
end
|
60 |
end
|