Skip to content

Commit 931208b

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 931208b

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

spec/classes/pg_repack_spec.rb

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +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
54-
5547
it {
5648
tables_hash.each do |name, val|
5749
is_expected.to contain_pe_databases__collect(name).with(
@@ -103,4 +95,21 @@ class {'pe_databases': facts_tables_repack_timer => 'Tue *-*-* 04:20:00'}
10395
)
10496
}
10597
end
98+
99+
context 'when customizing log parameters' do
100+
# Load the rspec hieradata. This data sets repack_log_level: 'INFO' and enable_echo: false
101+
let(:hiera_config) { 'hiera-rspec.yaml' }
102+
103+
it {
104+
# The command should have --elevel INFO and not contain --echo according to the hieradata
105+
is_expected.to contain_pe_databases__collect('facts').with(
106+
command: "#{repack_cmd} --elevel INFO #{tables_hash[:facts][:database]}",
107+
)
108+
109+
# The service file should have --elevel INFO and not contain --echo according to the hieradata
110+
is_expected.to contain_file('/etc/systemd/system/pe_databases-facts.service').with_content(
111+
%r{ExecStart=#{repack_cmd} --elevel INFO #{tables_hash[:facts][:database]} #{tables_hash[:facts][:tables]}},
112+
)
113+
}
114+
end
106115
end

0 commit comments

Comments
 (0)