fix: 修复 SQLite 连接复用导致数据库不可用
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
from sqlalchemy.pool import NullPool
|
||||
|
||||
from app.db import check_database_integrity, checkpoint_sqlite_wal, create_sqlite_engine, ensure_sqlite_schema_compat
|
||||
|
||||
@@ -11,6 +12,14 @@ def test_check_database_integrity_returns_ok_for_valid_sqlite_database():
|
||||
engine.dispose()
|
||||
|
||||
|
||||
def test_file_sqlite_engine_does_not_reuse_connections_after_operational_errors(tmp_path):
|
||||
engine = create_sqlite_engine(f"sqlite:///{tmp_path / 'app.db'}")
|
||||
try:
|
||||
assert isinstance(engine.pool, NullPool)
|
||||
finally:
|
||||
engine.dispose()
|
||||
|
||||
|
||||
def test_check_database_integrity_raises_when_sqlite_reports_problem(monkeypatch):
|
||||
class FakeCursor:
|
||||
def execute(self, _sql):
|
||||
|
||||
Reference in New Issue
Block a user