Skip to content

Commit

Permalink
Add tests to cover new repack log parameters
Browse files Browse the repository at this point in the history
This commit uses the new rspec specific hieradata to change the
parameters to the pg_repack class and tests them.
  • Loading branch information
m0dular committed Jan 30, 2024
1 parent ee1a976 commit 931208b
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions spec/classes/pg_repack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,23 @@
}
}
end
let(:pre_condition) do
<<-PRE_COND
define puppet_enterprise::deprecated_parameter() {}
include pe_databases
PRE_COND
end

on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:pre_condition) do
<<-PRE_COND
define puppet_enterprise::deprecated_parameter() {}
include pe_databases
PRE_COND
end
let(:facts) { os_facts }

it { is_expected.to compile }
end
end

context 'with default parameters' do
let(:pre_condition) do
<<-PRE_COND
define puppet_enterprise::deprecated_parameter() {}
include pe_databases
PRE_COND
end

it {
tables_hash.each do |name, val|
is_expected.to contain_pe_databases__collect(name).with(
Expand Down Expand Up @@ -103,4 +95,21 @@ class {'pe_databases': facts_tables_repack_timer => 'Tue *-*-* 04:20:00'}
)
}
end

context 'when customizing log parameters' do
# Load the rspec hieradata. This data sets repack_log_level: 'INFO' and enable_echo: false
let(:hiera_config) { 'hiera-rspec.yaml' }

it {
# The command should have --elevel INFO and not contain --echo according to the hieradata
is_expected.to contain_pe_databases__collect('facts').with(
command: "#{repack_cmd} --elevel INFO #{tables_hash[:facts][:database]}",
)

# The service file should have --elevel INFO and not contain --echo according to the hieradata
is_expected.to contain_file('/etc/systemd/system/pe_databases-facts.service').with_content(
%r{ExecStart=#{repack_cmd} --elevel INFO #{tables_hash[:facts][:database]} #{tables_hash[:facts][:tables]}},
)
}
end
end

0 comments on commit 931208b

Please sign in to comment.