Skip to content

Commit fc01e83

Browse files
committed
Remove use of spec_helper_acceptance in unit tests
In c96b073 the acceptance helper was included in the unit tests. This should never happen and breaks the tests. It appears it was included to have a postgresql_version but that should be defined in let blocks. The acceptance helper only works if there is an actual target machine. Fixes: c96b073
1 parent c8303fd commit fc01e83

File tree

1 file changed

+29
-42
lines changed

1 file changed

+29
-42
lines changed

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

0 commit comments

Comments
 (0)