From 9facc5d3277043b2b923fc86b0a1567d55f5b58a Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Wed, 25 Oct 2023 11:50:50 +0200 Subject: [PATCH 1/2] update values regex --- lib/puppet/type/postgresql_conf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/type/postgresql_conf.rb b/lib/puppet/type/postgresql_conf.rb index 432f5aa877..5cd753e20f 100644 --- a/lib/puppet/type/postgresql_conf.rb +++ b/lib/puppet/type/postgresql_conf.rb @@ -16,7 +16,7 @@ newproperty(:value) do desc 'The value to set for this parameter.' - newvalues(%r{^\S(.*\S)?$}) + newvalues(%r{^(\S.*)?$}) munge do |value| if value.to_i.to_s == value From e3dabd1ded2179b3e533243cce36d0e2c9b3c912 Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Wed, 25 Oct 2023 13:56:24 +0200 Subject: [PATCH 2/2] add spec tests for regex validation --- spec/unit/type/postgresql_conf_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/unit/type/postgresql_conf_spec.rb b/spec/unit/type/postgresql_conf_spec.rb index a2d54006be..f6e972f620 100644 --- a/spec/unit/type/postgresql_conf_spec.rb +++ b/spec/unit/type/postgresql_conf_spec.rb @@ -101,6 +101,12 @@ end # string https://www.postgresql.org/docs/current/datatype-character.html describe 'validate complex string values with newvalues function' do + it 'validates log_line_prefix with value [%p] %q:%u:%d:%' do + expect { described_class.new(name: 'log_line_prefix', value: '[%p] %q:%u:%d:%x ') }.not_to raise_error + end + it 'validates log_line_prefix with value %t %q%u@%d %p %i' do + expect { described_class.new(name: 'log_line_prefix', value: '%t %q%u@%d %p %i ') }.not_to raise_error + end it 'validates log_filename with value psql_01-%Y-%m-%d.log' do expect { described_class.new(name: 'log_filename', value: 'psql_01-%Y-%m-%d.log') }.not_to raise_error end