fix(tests): provenance itest user fixture is get-or-create — the lane DB persists across tests
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 11s
CI & Build / integration (push) Successful in 21s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 53s
CI & Build / Build & push image (push) Successful in 19s
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 11s
CI & Build / integration (push) Successful in 21s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 53s
CI & Build / Build & push image (push) Successful in 19s
Both integration tests built the same username; the second insert died on users_username_key. 19 passed, 1 error on run 3802. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -88,10 +88,21 @@ async def _dispose_engine():
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def user_id(_dispose_engine):
|
||||
# Get-or-create: the lane's database persists across tests, so a second
|
||||
# test re-creating the same username dies on the unique constraint.
|
||||
from sqlalchemy import select
|
||||
|
||||
from scribe.models import async_session
|
||||
from scribe.models.user import User
|
||||
|
||||
async with async_session() as s:
|
||||
existing = (
|
||||
await s.execute(
|
||||
select(User).where(User.username == "snippet_prov_itest")
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
if existing is not None:
|
||||
return existing.id
|
||||
user = User(username="snippet_prov_itest")
|
||||
s.add(user)
|
||||
await s.flush()
|
||||
|
||||
Reference in New Issue
Block a user