File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -384,4 +384,30 @@ class {'postgresql::server':}
384
384
it { is_expected . to compile . and_raise_error ( %r{parameter 'object_name' variant 0 expects size to be 2, got 3} ) }
385
385
end
386
386
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
You can’t perform that action at this time.
0 commit comments