Skip to content

Commit c96bf07

Browse files
committed
added rspec on specific schema name only if object exists
1 parent 30503af commit c96bf07

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

spec/defines/server/grant_spec.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,30 @@ class {'postgresql::server':}
384384
it { is_expected.to compile.and_raise_error(%r{parameter 'object_name' variant 0 expects size to be 2, got 3}) }
385385
end
386386
end
387-
end
387+
388+
context 'with specific schema name only if object exists' do
389+
let :params do
390+
{
391+
db: 'test',
392+
role: 'test',
393+
privilege: 'all',
394+
object_name: ['myschema', 'mytable'],
395+
object_type: 'table',
396+
onlyif_exists: true,
397+
}
398+
end
399+
400+
let :pre_condition do
401+
"class {'postgresql::server':}"
402+
end
403+
404+
it { is_expected.to compile.with_all_deps }
405+
it { is_expected.to contain_postgresql__server__grant('test') }
406+
it do
407+
is_expected.to contain_postgresql_psql('grant:test')
408+
.with_command(%r{GRANT ALL ON TABLE "myschema"."mytable" TO\s* "test"}m)
409+
.with_unless(%r{SELECT 1 WHERE has_table_privilege\('test',\s*'myschema.mytable', 'INSERT'\)}m)
410+
.with_onlyif(%r{SELECT true FROM pg_tables WHERE tablename = 'mytable'}m)
411+
end
412+
end
413+
end

0 commit comments

Comments
 (0)