@@ -3,7 +3,7 @@ import { pgMeta } from './utils'
33test ( 'list' , async ( ) => {
44 const res = await pgMeta . roles . list ( )
55
6- const role : any = res . data ?. find ( ( { name } ) => name === 'postgres' )
6+ let role = res . data ?. find ( ( { name } ) => name === 'postgres' )
77
88 expect ( role ) . toMatchInlineSnapshot (
99 { active_connections : expect . any ( Number ) , id : expect . any ( Number ) } ,
@@ -26,6 +26,43 @@ test('list', async () => {
2626 }
2727 `
2828 )
29+
30+ // pg_monitor is a predefined role. `includeDefaultRoles` defaults to false,
31+ // so it shouldn't be included in the result.
32+ role = res . data ?. find ( ( { name } ) => name === 'pg_monitor' )
33+
34+ expect ( role ) . toMatchInlineSnapshot ( `undefined` )
35+ } )
36+
37+ test ( 'list w/ default roles' , async ( ) => {
38+ const res = await pgMeta . roles . list ( { includeDefaultRoles : true } )
39+
40+ const role = res . data ?. find ( ( { name } ) => name === 'pg_monitor' )
41+
42+ expect ( role ) . toMatchInlineSnapshot (
43+ {
44+ active_connections : expect . any ( Number ) ,
45+ id : expect . any ( Number ) ,
46+ } ,
47+ `
48+ {
49+ "active_connections": Any<Number>,
50+ "can_bypass_rls": false,
51+ "can_create_db": false,
52+ "can_create_role": false,
53+ "can_login": false,
54+ "config": null,
55+ "connection_limit": 100,
56+ "id": Any<Number>,
57+ "inherit_role": true,
58+ "is_replication_role": false,
59+ "is_superuser": false,
60+ "name": "pg_monitor",
61+ "password": "********",
62+ "valid_until": null,
63+ }
64+ `
65+ )
2966} )
3067
3168test ( 'retrieve, create, update, delete' , async ( ) => {
0 commit comments