"""Instance fields (database/table listing) tests — Go/Gin backend.""" import pytest from httpx import AsyncClient from tests.conftest import auth_header class TestInstanceFields: async def test_list_databases(self, client: AsyncClient, admin_token: str, test_mysql_instance): resp = await client.get( f"/api/v1/instances/{test_mysql_instance['id']}/databases", headers=auth_header(admin_token), ) assert resp.status_code == 200 async def test_list_tables(self, client: AsyncClient, admin_token: str, test_mysql_instance): # First get a database name db_resp = await client.get( f"/api/v1/instances/{test_mysql_instance['id']}/databases", headers=auth_header(admin_token), ) dbs = db_resp.json() if not dbs: pytest.skip("No databases available") db_name = dbs[0] if isinstance(dbs[0], str) else dbs[0].get("name", "test") resp = await client.get( f"/api/v1/instances/{test_mysql_instance['id']}/databases/{db_name}/tables", headers=auth_header(admin_token), ) assert resp.status_code == 200 async def test_no_auth(self, client: AsyncClient): resp = await client.get("/api/v1/instances/4/databases") assert resp.status_code == 401