feat: TDD Phase 1 — 44 backend API tests passing
Test infrastructure: - conftest.py with SQLite in-memory DB, isolated per-test cleanup - pytest.ini with asyncio auto mode - Fixtures: admin/dba/developer/guest/disabled users, tokens, test instance Test coverage (44 tests): - test_auth: login/logout/me/token expiry (8 tests) - test_users: CRUD + role permissions (8 tests) - test_instances: CRUD + connection test mock (8 tests) - test_tickets: CRUD + review/execute workflow + pagination (11 tests) - test_query: select/drop/delete rejection + guest deny (4 tests) - test_dashboard: stats + auth check (2 tests) Backend fix: - query endpoint now catches ValueError from QueryService → 400 instead of 500 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
439155c92e
commit
c0c731acfc
10 files changed
+707
-1
No files matched your search
@@ -27,7 +27,10 @@ async def execute_query(
|
||||
if not instance:
|
||||
raise HTTPException(status_code=404, detail="数据源不存在")
|
||||
|
||||
query_result = await QueryService.execute_query(instance, req.database, req.sql, current_user.id)
|
||||
try:
|
||||
query_result = await QueryService.execute_query(instance, req.database, req.sql, current_user.id)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
# Record audit log
|
||||
log = AuditLog(
|
||||
|
||||
Reference in new issue
Block a user