Skip to content

Commit 8b08ab3

Browse files
committed
Add tests to cover new repack log parameters
This commit uses the new rspec specific hieradata to change the parameters to the pg_repack class and tests them.
1 parent ee1a976 commit 8b08ab3

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

spec/classes/pg_repack_spec.rb

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,23 @@
2727
}
2828
}
2929
end
30+
let(:pre_condition) do
31+
<<-PRE_COND
32+
define puppet_enterprise::deprecated_parameter() {}
33+
34+
include pe_databases
35+
PRE_COND
36+
end
3037

3138
on_supported_os.each do |os, os_facts|
3239
context "on #{os}" do
33-
let(:pre_condition) do
34-
<<-PRE_COND
35-
define puppet_enterprise::deprecated_parameter() {}
36-
37-
include pe_databases
38-
PRE_COND
39-
end
4040
let(:facts) { os_facts }
4141

4242
it { is_expected.to compile }
4343
end
4444
end
4545

4646
context 'with default parameters' do
47-
let(:pre_condition) do
48-
<<-PRE_COND
49-
define puppet_enterprise::deprecated_parameter() {}
50-
51-
include pe_databases
52-
PRE_COND
53-
end
5447

5548
it {
5649
tables_hash.each do |name, val|
@@ -103,4 +96,21 @@ class {'pe_databases': facts_tables_repack_timer => 'Tue *-*-* 04:20:00'}
10396
)
10497
}
10598
end
99+
100+
context 'when customizing log parameters' do
101+
# Load the rspec hieradata. This data sets repack_log_level: 'INFO' and enable_echo: false
102+
let(:hiera_config) { 'hiera-rspec.yaml' }
103+
104+
it {
105+
# The command should have --elevel INFO and not contain --echo according to the hieradata
106+
is_expected.to contain_pe_databases__collect('facts').with(
107+
command: "#{repack_cmd} --elevel INFO #{tables_hash[:facts][:database]}"
108+
)
109+
110+
# The service file should have --elevel INFO and not contain --echo according to the hieradata
111+
is_expected.to contain_file("/etc/systemd/system/pe_databases-facts.service").with_content(
112+
%r{ExecStart=#{repack_cmd} --elevel INFO #{tables_hash[:facts][:database]} #{tables_hash[:facts][:tables]}},
113+
)
114+
}
115+
end
106116
end

0 commit comments

Comments
 (0)