mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
test(server): seed the small specs through the repositories
The suites with one to three raw statements left now seed and read their rows through the ORM factories instead of hand-written SQLite on the better-sqlite3 handle. A legacy statement that serves as a parity oracle, the schema introspection and the bare backup file keep their raw SQL and say why with a test-sql-allow marker. Two database mocks still answered a getPlaceWithTags the module no longer exports; that dead branch goes too, and the budget seam suite stubs the reservations repository directly instead of a fake prepare().
This commit is contained in:
@@ -67,7 +67,9 @@ import { db as testDb } from '../../src/db/database';
|
||||
import { buildApp } from '../../src/bootstrap';
|
||||
import { CalendarService } from '../../src/nest/calendar/calendar.service';
|
||||
import { Trips } from '../../src/db/entities/Trips.entity';
|
||||
import { Users } from '../../src/db/entities/Users.entity';
|
||||
import { createTrip, createUser } from '../helpers/factories';
|
||||
import { updateRows } from '../helpers/factories/rows';
|
||||
|
||||
describe('Anonymous ICS feed routes run inside a request context', () => {
|
||||
let app: INestApplication;
|
||||
@@ -86,7 +88,7 @@ describe('Anonymous ICS feed routes run inside a request context', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id, { title: 'Context-Proof Trip' });
|
||||
const token = randomUUID();
|
||||
testDb.prepare('UPDATE trips SET feed_token = ? WHERE id = ?').run(token, trip.id);
|
||||
await updateRows(app.get(MikroORM), Trips, { id: trip.id }, { feed_token: token });
|
||||
|
||||
let repoRead: unknown;
|
||||
let caught: unknown;
|
||||
@@ -136,7 +138,7 @@ describe('Anonymous ICS feed routes run inside a request context', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id, { title: 'Mutation-Proof Trip' });
|
||||
const token = randomUUID();
|
||||
testDb.prepare('UPDATE trips SET feed_token = ? WHERE id = ?').run(token, trip.id);
|
||||
await updateRows(app.get(MikroORM), Trips, { id: trip.id }, { feed_token: token });
|
||||
|
||||
const calendar = app.get(CalendarService);
|
||||
const spy = vi.spyOn(calendar, 'buildTripCalendar').mockImplementation(async () => {
|
||||
@@ -184,7 +186,7 @@ describe('Anonymous ICS feed routes run inside a request context', () => {
|
||||
const { user } = createUser(testDb);
|
||||
createTrip(testDb, user.id, { title: 'User-Feed Context-Proof Trip' });
|
||||
const token = randomUUID();
|
||||
testDb.prepare('UPDATE users SET feed_token = ? WHERE id = ?').run(token, user.id);
|
||||
await updateRows(app.get(MikroORM), Users, { id: user.id }, { feed_token: token });
|
||||
|
||||
let repoRead: unknown;
|
||||
let caught: unknown;
|
||||
|
||||
Reference in New Issue
Block a user