Skip to content

Commit 3ddc7bb

Browse files
add spec tests for regex validation
1 parent 4a031cb commit 3ddc7bb

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

spec/unit/type/postgresql_conf_spec.rb

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,74 @@
5151
expect { described_class.new(name: 'foo', ensure: :foo) }.to raise_error(Puppet::Error, %r{Invalid value})
5252
end
5353
end
54+
# boolean https://www.postgresql.org/docs/current/datatype-boolean.html
55+
describe 'validate boolean values with newvalues function' do
56+
it 'validates log_checkpoints with value on' do
57+
expect { described_class.new(name: 'log_checkpoints', value: 'on') }.not_to raise_error
58+
end
59+
it 'validates log_checkpoints with value off' do
60+
expect { described_class.new(name: 'log_checkpoints', value: 'off') }.not_to raise_error
61+
end
62+
it 'validates log_checkpoints with value true' do
63+
expect { described_class.new(name: 'log_checkpoints', value: 'true') }.not_to raise_error
64+
end
65+
it 'validates log_checkpoints with value false' do
66+
expect { described_class.new(name: 'log_checkpoints', value: 'false') }.not_to raise_error
67+
end
68+
it 'validates log_checkpoints with value yes' do
69+
expect { described_class.new(name: 'log_checkpoints', value: 'yes') }.not_to raise_error
70+
end
71+
it 'validates log_checkpoints with value no' do
72+
expect { described_class.new(name: 'log_checkpoints', value: 'no') }.not_to raise_error
73+
end
74+
it 'validates log_checkpoints with value 1' do
75+
expect { described_class.new(name: 'log_checkpoints', value: '1') }.not_to raise_error
76+
end
77+
it 'validates log_checkpoints with value 0' do
78+
expect { described_class.new(name: 'log_checkpoints', value: '0') }.not_to raise_error
79+
end
80+
end
81+
# enums https://www.postgresql.org/docs/current/datatype-enum.html
82+
describe 'validate enum values with newvalues function' do
83+
it 'validates ssl_min_protocol_version with value TLSv1.3' do
84+
expect { described_class.new(name: 'ssl_min_protocol_version', value: 'TLSv1.3') }.not_to raise_error
85+
end
86+
it 'validates ssl_min_protocol_version with value TLSv1.1' do
87+
expect { described_class.new(name: 'ssl_min_protocol_version', value: 'TLSv1.1') }.not_to raise_error
88+
end
89+
end
90+
# integer https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-INT
91+
describe 'validate integer values with newvalues function' do
92+
it 'validates max_connections with value 1000' do
93+
expect { described_class.new(name: 'max_connections', value: '1000') }.not_to raise_error
94+
end
95+
end
96+
# real https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT
97+
describe 'validate real values with newvalues function' do
98+
it 'validates parallel_tuple_cost with value 0.3' do
99+
expect { described_class.new(name: 'parallel_tuple_cost', value: '0.3') }.not_to raise_error
100+
end
101+
end
102+
# string https://www.postgresql.org/docs/current/datatype-character.html
103+
describe 'validate complex string values with newvalues function' do
104+
it 'validates log_line_prefix with value [%p] %q:%u:%d:%' do
105+
expect { described_class.new(name: 'log_line_prefix', value: '[%p] %q:%u:%d:%x ') }.not_to raise_error
106+
end
107+
it 'validates log_line_prefix with value %t %q%u@%d %p %i' do
108+
expect { described_class.new(name: 'log_line_prefix', value: '%t %q%u@%d %p %i ') }.not_to raise_error
109+
end
110+
it 'validates log_filename with value psql_01-%Y-%m-%d.log' do
111+
expect { described_class.new(name: 'log_filename', value: 'psql_01-%Y-%m-%d.log') }.not_to raise_error
112+
end
113+
end
114+
# string https://www.postgresql.org/docs/current/datatype-character.html
115+
describe 'validate string values with newvalues function' do
116+
it 'validates log_timezone with value UTC' do
117+
expect { described_class.new(name: 'log_timezone', value: 'UTC') }.not_to raise_error
118+
end
119+
it 'validates ssl_ciphers with value HIGH:MEDIUM:+3DES:!aNULL' do
120+
expect { described_class.new(name: 'ssl_ciphers', value: 'HIGH:MEDIUM:+3DES:!aNULL') }.not_to raise_error
121+
end
122+
end
54123
end
55124
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy