@@ -231,14 +231,31 @@ def test_sync_permissions_command_async_mode_new_db_name(
231231 async_task_mock .delay .assert_called_once_with (1 , "admin" , "Old Name" )
232232
233233
234- def test_resync_permissions_command_get_catalogs (database_with_catalog : MagicMock ):
234+ def test_sync_permissions_command_get_catalogs (database_with_catalog : MagicMock ):
235235 """
236236 Test the ``_get_catalog_names`` method.
237237 """
238238 cmmd = SyncPermissionsCommand (1 , None , db_connection = database_with_catalog )
239239 assert cmmd ._get_catalog_names () == ["catalog1" , "catalog2" ]
240240
241241
242+ def test_sync_permissions_command_get_default_catalog (database_with_catalog : MagicMock ):
243+ """
244+ Test ``_get_catalog_names`` when only the default one should be returned.
245+
246+ When the database doesn't not support cross-catalog queries (like Postgres), we
247+ should only return all catalogs if multi-catalog is enabled.
248+ """
249+ database_with_catalog .db_engine_spec .supports_cross_catalog_queries = False
250+ database_with_catalog .allow_multi_catalog = False
251+ cmmd = SyncPermissionsCommand (1 , None , db_connection = database_with_catalog )
252+ assert cmmd ._get_catalog_names () == {"catalog2" }
253+
254+ database_with_catalog .allow_multi_catalog = True
255+ cmmd = SyncPermissionsCommand (1 , None , db_connection = database_with_catalog )
256+ assert cmmd ._get_catalog_names () == ["catalog1" , "catalog2" ]
257+
258+
242259@pytest .mark .parametrize (
243260 ("inner_exception, outer_exception" ),
244261 [
@@ -249,7 +266,7 @@ def test_resync_permissions_command_get_catalogs(database_with_catalog: MagicMoc
249266 (GenericDBException , DatabaseConnectionFailedError ),
250267 ],
251268)
252- def test_resync_permissions_command_raise_on_getting_catalogs (
269+ def test_sync_permissions_command_raise_on_getting_catalogs (
253270 inner_exception : Exception ,
254271 outer_exception : Exception ,
255272 database_with_catalog : MagicMock ,
@@ -263,7 +280,7 @@ def test_resync_permissions_command_raise_on_getting_catalogs(
263280 cmmd ._get_catalog_names ()
264281
265282
266- def test_resync_permissions_command_get_schemas (database_with_catalog : MagicMock ):
283+ def test_sync_permissions_command_get_schemas (database_with_catalog : MagicMock ):
267284 """
268285 Test the ``_get_schema_names`` method.
269286 """
@@ -282,7 +299,7 @@ def test_resync_permissions_command_get_schemas(database_with_catalog: MagicMock
282299 (GenericDBException , DatabaseConnectionFailedError ),
283300 ],
284301)
285- def test_resync_permissions_command_raise_on_getting_schemas (
302+ def test_sync_permissions_command_raise_on_getting_schemas (
286303 inner_exception : Exception ,
287304 outer_exception : Exception ,
288305 database_with_catalog : MagicMock ,
@@ -296,7 +313,7 @@ def test_resync_permissions_command_raise_on_getting_schemas(
296313 cmmd ._get_schema_names ("blah" )
297314
298315
299- def test_resync_permissions_command_refresh_schemas (
316+ def test_sync_permissions_command_refresh_schemas (
300317 mocker : MockerFixture , database_with_catalog : MagicMock
301318):
302319 """
@@ -319,7 +336,7 @@ def test_resync_permissions_command_refresh_schemas(
319336 )
320337
321338
322- def test_resync_permissions_command_rename_db_in_perms (
339+ def test_sync_permissions_command_rename_db_in_perms (
323340 mocker : MockerFixture , database_with_catalog : MagicMock
324341):
325342 """
0 commit comments