Skip to content

Commit 09b242a

Browse files
authored
Merge pull request #1291 from ekohl/fix-tests
[IAC-1735] Fix test suite
2 parents 7f3ac0c + fc01e83 commit 09b242a

File tree

3 files changed

+35
-48
lines changed

3 files changed

+35
-48
lines changed

spec/unit/classes/server/config_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
end
3333

3434
it 'has SELinux port defined' do
35-
is_expected.to contain_package('policycoreutils-python') .with(ensure: 'present')
35+
is_expected.to contain_package('policycoreutils-python').with(ensure: 'installed')
3636

3737
is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
3838
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
@@ -141,7 +141,7 @@ class { 'postgresql::server': }
141141
end
142142

143143
it 'has SELinux port defined' do
144-
is_expected.to contain_package('policycoreutils-python-utils') .with(ensure: 'present')
144+
is_expected.to contain_package('policycoreutils-python-utils').with(ensure: 'installed')
145145

146146
is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
147147
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
@@ -214,7 +214,7 @@ class { 'postgresql::server': }
214214
end
215215

216216
it 'has SELinux port defined' do
217-
is_expected.to contain_package('policycoreutils-python-utils') .with(ensure: 'present')
217+
is_expected.to contain_package('policycoreutils-python-utils').with(ensure: 'installed')
218218

219219
is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
220220
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
@@ -282,7 +282,7 @@ class { 'postgresql::server': }
282282
end
283283

284284
it 'has SELinux port defined' do
285-
is_expected.to contain_package('policycoreutils') .with(ensure: 'present')
285+
is_expected.to contain_package('policycoreutils').with(ensure: 'installed')
286286

287287
is_expected.to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
288288
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')

spec/unit/defines/server/default_privileges_spec.rb

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'spec_helper'
4-
require 'spec_helper_acceptance'
54

65
describe 'postgresql::server::default_privileges', type: :define do
76
let :facts do
@@ -65,13 +64,11 @@
6564
"class {'postgresql::server':}"
6665
end
6766

68-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
69-
it { is_expected.to compile.with_all_deps }
70-
it { is_expected.to contain_postgresql__server__default_privileges('test') }
71-
it do
72-
is_expected.to contain_postgresql_psql('default_privileges:test')
73-
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
74-
end
67+
it { is_expected.to compile.with_all_deps }
68+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
69+
it do
70+
is_expected.to contain_postgresql_psql('default_privileges:test')
71+
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
7572
end
7673
end
7774

@@ -90,9 +87,7 @@
9087
"class {'postgresql::server':}"
9188
end
9289

93-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
94-
it { is_expected.to compile.and_raise_error(%r{parameter 'object_type' expects a match for Pattern}) }
95-
end
90+
it { is_expected.to compile.and_raise_error(%r{parameter 'object_type' expects a match for Pattern}) }
9691
end
9792
end
9893

@@ -111,16 +106,14 @@
111106
"class {'postgresql::server':}"
112107
end
113108

114-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
115-
it { is_expected.to compile.with_all_deps }
116-
it { is_expected.to contain_postgresql__server__default_privileges('test') }
117-
it do
118-
# rubocop:disable Layout/LineLength
119-
is_expected.to contain_postgresql_psql('default_privileges:test')
120-
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
121-
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'public' and defaclobjtype = 'r')")
122-
# rubocop:enable Layout/LineLength
123-
end
109+
it { is_expected.to compile.with_all_deps }
110+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
111+
it do
112+
# rubocop:disable Layout/LineLength
113+
is_expected.to contain_postgresql_psql('default_privileges:test')
114+
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
115+
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'public' and defaclobjtype = 'r')")
116+
# rubocop:enable Layout/LineLength
124117
end
125118
end
126119

@@ -138,9 +131,7 @@
138131
"class {'postgresql::server':}"
139132
end
140133

141-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
142-
it { is_expected.to compile.and_raise_error(%r{Illegal value for \$privilege parameter}) }
143-
end
134+
it { is_expected.to compile.and_raise_error(%r{Illegal value for \$privilege parameter}) }
144135
end
145136
end
146137

@@ -225,16 +216,14 @@
225216
"class {'postgresql::server':}"
226217
end
227218

228-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
229-
it { is_expected.to compile.with_all_deps }
230-
it { is_expected.to contain_postgresql__server__default_privileges('test') }
231-
it do
232-
# rubocop:disable Layout/LineLength
233-
is_expected.to contain_postgresql_psql('default_privileges:test')
234-
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA my_schema GRANT ALL ON TABLES TO "test"')
235-
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'my_schema' and defaclobjtype = 'r')")
236-
# rubocop:enable Layout/LineLength
237-
end
219+
it { is_expected.to compile.with_all_deps }
220+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
221+
it do
222+
# rubocop:disable Layout/LineLength
223+
is_expected.to contain_postgresql_psql('default_privileges:test')
224+
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA my_schema GRANT ALL ON TABLES TO "test"')
225+
.with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE 'test=arwdDxt' = ANY (defaclacl) AND nspname = 'my_schema' and defaclobjtype = 'r')")
226+
# rubocop:enable Layout/LineLength
238227
end
239228
end
240229

@@ -255,14 +244,12 @@ class {'postgresql::server':}
255244
EOS
256245
end
257246

258-
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
259-
it { is_expected.to compile.with_all_deps }
260-
it { is_expected.to contain_postgresql__server__default_privileges('test') }
261-
it { is_expected.to contain_postgresql__server__role('test') }
262-
it do
263-
is_expected.to contain_postgresql_psql('default_privileges:test') \
264-
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
265-
end
247+
it { is_expected.to compile.with_all_deps }
248+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
249+
it { is_expected.to contain_postgresql__server__role('test') }
250+
it do
251+
is_expected.to contain_postgresql_psql('default_privileges:test') \
252+
.that_requires(['Service[postgresqld]', 'Postgresql::Server::Role[test]'])
266253
end
267254
end
268255

spec/unit/defines/server/extension_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
it {
5656
is_expected.to contain_package('postgis')
57-
.with(ensure: 'present', name: 'postgis').that_comes_before('Postgresql_psql[template_postgis: CREATE EXTENSION "postgis"]')
57+
.with(ensure: 'installed', name: 'postgis').that_comes_before('Postgresql_psql[template_postgis: CREATE EXTENSION "postgis"]')
5858
}
5959
end
6060

@@ -86,7 +86,7 @@
8686

8787
it {
8888
is_expected.to contain_package('postgis')
89-
.with(ensure: 'present', name: 'postgis').that_requires('Postgresql_psql[template_postgis: DROP EXTENSION "postgis"]')
89+
.with(ensure: 'installed', name: 'postgis').that_requires('Postgresql_psql[template_postgis: DROP EXTENSION "postgis"]')
9090
}
9191
end
9292
end

0 commit comments

Comments
 (0)