Skip to content

Commit a3f6eeb

Browse files
Merge pull request #1546 from bastelfreak/tests2
postgresql_conf: add spec tests for value param
2 parents d4560c1 + dfca7cd commit a3f6eeb

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

spec/unit/type/postgresql_conf_spec.rb

+63
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,68 @@
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_filename with value psql_01-%Y-%m-%d.log' do
105+
expect { described_class.new(name: 'log_filename', value: 'psql_01-%Y-%m-%d.log') }.not_to raise_error
106+
end
107+
end
108+
# string https://www.postgresql.org/docs/current/datatype-character.html
109+
describe 'validate string values with newvalues function' do
110+
it 'validates log_timezone with value UTC' do
111+
expect { described_class.new(name: 'log_timezone', value: 'UTC') }.not_to raise_error
112+
end
113+
it 'validates ssl_ciphers with value HIGH:MEDIUM:+3DES:!aNULL' do
114+
expect { described_class.new(name: 'ssl_ciphers', value: 'HIGH:MEDIUM:+3DES:!aNULL') }.not_to raise_error
115+
end
116+
end
54117
end
55118
end

0 commit comments

Comments
 (0)