Skip to content
Sarj Code Standards

no-recording-store

Use the PostgreSQL store in tests instead of a recording-only store implementation.

Why

An in-memory store double proves that a method was called but bypasses SQL, constraints, transactions and concurrency behavior. It can accept operations the real store rejects.

Fix

Inject the real PostgreSQL store with an isolated database fixture and assert persisted state. Keep operational observability around real persistence rather than replacing persistence with an appended call list.

Examples

Before — flagged Recording replaces persistence
tests/fakes/store.py
class Store:
def get(self, key): ...
def upsert(self, item): ...
class Recording(Store):
def __init__(self):
self.writes = []
def upsert(self, item):
self.writes.append(item)
return item
After — preferred A spy retains actual persistence
tests/fakes/store.py
class Store:
def get(self, key): ...
def upsert(self, item): ...
class Recording(Store):
def __init__(self):
self.writes = []
def upsert(self, item):
self.writes.append(item)
return super().upsert(item)