Skip to content

Commit b2e3f7d

Browse files
committed
Fixup for tests
1 parent 3d8a411 commit b2e3f7d

File tree

2 files changed

+54
-38
lines changed

2 files changed

+54
-38
lines changed

spec/acceptance/server/default_privileges_spec.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,25 @@ class { 'postgresql::server': }
6969
end
7070

7171
it 'grants default privileges to an user' do
72-
idempotent_apply(pp_one)
72+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
73+
idempotent_apply(pp_one)
7374

74-
psql("--command=\"SET client_min_messages = 'error';#{check_command}\" --db=#{db}") do |r|
75-
expect(r.stdout).to match(%r{\(1 row\)})
76-
expect(r.stderr).to eq('')
75+
psql("--command=\"SET client_min_messages = 'error';#{check_command}\" --db=#{db}") do |r|
76+
expect(r.stdout).to match(%r{\(1 row\)})
77+
expect(r.stderr).to eq('')
78+
end
7779
end
7880
end
7981

8082
it 'revokes default privileges for an user' do
81-
apply_manifest(pp_one, catch_failures: true)
82-
apply_manifest(pp_two, expect_changes: true)
83+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
84+
apply_manifest(pp_one, catch_failures: true)
85+
apply_manifest(pp_two, expect_changes: true)
8386

84-
psql("--command=\"SET client_min_messages = 'error';#{check_command}\" --db=#{db}") do |r|
85-
expect(r.stdout).to match(%r{\(0 rows\)})
86-
expect(r.stderr).to eq('')
87+
psql("--command=\"SET client_min_messages = 'error';#{check_command}\" --db=#{db}") do |r|
88+
expect(r.stdout).to match(%r{\(0 rows\)})
89+
expect(r.stderr).to eq('')
90+
end
8791
end
8892
end
8993
end

spec/unit/defines/server/default_privileges_spec.rb

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@
6464
"class {'postgresql::server':}"
6565
end
6666

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"')
67+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
68+
it { is_expected.to compile.with_all_deps }
69+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
70+
it do
71+
is_expected.to contain_postgresql_psql('default_privileges:test')
72+
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
73+
end
7274
end
7375
end
7476

@@ -87,7 +89,9 @@
8789
"class {'postgresql::server':}"
8890
end
8991

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

@@ -106,14 +110,16 @@
106110
"class {'postgresql::server':}"
107111
end
108112

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
113+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
114+
it { is_expected.to compile.with_all_deps }
115+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
116+
it do
117+
# rubocop:disable Layout/LineLength
118+
is_expected.to contain_postgresql_psql('default_privileges:test')
119+
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO "test"')
120+
.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')")
121+
# rubocop:enable Layout/LineLength
122+
end
117123
end
118124
end
119125

@@ -131,7 +137,9 @@
131137
"class {'postgresql::server':}"
132138
end
133139

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

@@ -216,14 +224,16 @@
216224
"class {'postgresql::server':}"
217225
end
218226

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
227+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
228+
it { is_expected.to compile.with_all_deps }
229+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
230+
it do
231+
# rubocop:disable Layout/LineLength
232+
is_expected.to contain_postgresql_psql('default_privileges:test')
233+
.with_command('ALTER DEFAULT PRIVILEGES IN SCHEMA my_schema GRANT ALL ON TABLES TO "test"')
234+
.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')")
235+
# rubocop:enable Layout/LineLength
236+
end
227237
end
228238
end
229239

@@ -244,12 +254,14 @@ class {'postgresql::server':}
244254
EOS
245255
end
246256

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(['Class[postgresql::server::service]', 'Postgresql::Server::Role[test]'])
257+
if Gem::Version.new(postgresql_version) >= Gem::Version.new('9.6')
258+
it { is_expected.to compile.with_all_deps }
259+
it { is_expected.to contain_postgresql__server__default_privileges('test') }
260+
it { is_expected.to contain_postgresql__server__role('test') }
261+
it do
262+
is_expected.to contain_postgresql_psql('default_privileges:test') \
263+
.that_requires(['Class[postgresql::server::service]', 'Postgresql::Server::Role[test]'])
264+
end
253265
end
254266
end
255267

0 commit comments

Comments
 (0)