Skip to content

Commit 4dd5905

Browse files
committed
test: type the new pins' engine options and drop the REST pin's console spies
Claude-Session: https://claude.ai/code/session_01ADHkmQQoWsHzMSsiaM89mr Co-authored-by: Claude <noreply@anthropic.com>
1 parent f1eec6f commit 4dd5905

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

‎packages/objectql/src/engine-cascade-summary-rollback.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const ids = (rows: Row[]) => rows.map((r) => r.id).sort();
142142
describe('a cascade dependent\'s ERR_SUMMARY_RECOMPUTE never answers for a parent delete that did not land', () => {
143143
it('atomic plan: the parent delete refuses with another error, and nothing stored changes', async () => {
144144
const { engine, driver } = await makeEngine(true);
145-
const err: any = await engine.delete('acct', { where: { id: 'a1' } } as any).then(() => null, (e: unknown) => e);
145+
const err: any = await engine.delete('acct', { where: { id: 'a1' } }).then(() => null, (e: unknown) => e);
146146
expect(err).toBeInstanceOf(Error);
147147
expect(err.code).toBeUndefined();
148148
expect(err.cause?.code).toBe('ERR_SUMMARY_RECOMPUTE');
@@ -154,7 +154,7 @@ describe('a cascade dependent\'s ERR_SUMMARY_RECOMPUTE never answers for a paren
154154

155155
it('a runtime that cannot roll back: the parent is still stored, and the caller is refused', async () => {
156156
const { engine, driver } = await makeEngine(false);
157-
const err: any = await engine.delete('acct', { where: { id: 'a1' } } as any).then(() => null, (e: unknown) => e);
157+
const err: any = await engine.delete('acct', { where: { id: 'a1' } }).then(() => null, (e: unknown) => e);
158158
expect(err).toBeInstanceOf(Error);
159159
expect(err.code).toBeUndefined();
160160
expect(err.cause?.code).toBe('ERR_SUMMARY_RECOMPUTE');
@@ -165,7 +165,7 @@ describe('a cascade dependent\'s ERR_SUMMARY_RECOMPUTE never answers for a paren
165165

166166
it('a predicate delete (multi) on a runtime that cannot roll back: refused the same way, the parent still stored', async () => {
167167
const { engine, driver } = await makeEngine(false);
168-
const err: any = await engine.delete('acct', { where: { name: 'A' }, multi: true } as any).then(() => null, (e: unknown) => e);
168+
const err: any = await engine.delete('acct', { where: { name: 'A' }, multi: true }).then(() => null, (e: unknown) => e);
169169
expect(err).toBeInstanceOf(Error);
170170
expect(err.code).toBeUndefined();
171171
expect(err.cause?.code).toBe('ERR_SUMMARY_RECOMPUTE');
@@ -175,7 +175,7 @@ describe('a cascade dependent\'s ERR_SUMMARY_RECOMPUTE never answers for a paren
175175
it('a caller\'s own transaction that the refusal rolls back: refused with another error, nothing stored', async () => {
176176
const { engine, driver } = await makeEngine(true);
177177
const err: any = await engine
178-
.transaction(async (trx: any) => engine.delete('line', { where: { id: 'l1' }, context: trx } as any))
178+
.transaction(async (trx: any) => engine.delete('line', { where: { id: 'l1' }, context: trx }))
179179
.then(() => null, (e: unknown) => e);
180180
expect(err).toBeInstanceOf(Error);
181181
expect(err.code).toBeUndefined();
@@ -199,7 +199,7 @@ describe('a cascade dependent\'s ERR_SUMMARY_RECOMPUTE never answers for a paren
199199

200200
it('CONTROL the dependent\'s own delete landed: ERR_SUMMARY_RECOMPUTE, carrying its result', async () => {
201201
const { engine, driver } = await makeEngine(true);
202-
const err: any = await engine.delete('line', { where: { id: 'l1' } } as any).then(() => null, (e: unknown) => e);
202+
const err: any = await engine.delete('line', { where: { id: 'l1' } }).then(() => null, (e: unknown) => e);
203203
expect(err?.code).toBe('ERR_SUMMARY_RECOMPUTE');
204204
expect(err.written).toBe(true);
205205
expect(ids(driver.rowsOf('line'))).toEqual(['l2']);
@@ -209,7 +209,7 @@ describe('a cascade dependent\'s ERR_SUMMARY_RECOMPUTE never answers for a paren
209209
const { engine, driver } = await makeEngine(true);
210210
let caught: any;
211211
await engine.transaction(async (trx: any) => {
212-
await engine.delete('line', { where: { id: 'l1' }, context: trx } as any).catch((e: unknown) => { caught = e; });
212+
await engine.delete('line', { where: { id: 'l1' }, context: trx }).catch((e: unknown) => { caught = e; });
213213
});
214214
expect(caught?.code).toBe('ERR_SUMMARY_RECOMPUTE');
215215
expect(driver.rolledBack).toHaveLength(0);

‎packages/rest/src/data-delete-cascade-summary-rollback.test.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* publish gate refused it would be.
3232
*/
3333

34-
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
34+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
3535
import { mkdtempSync, rmSync } from 'node:fs';
3636
import { tmpdir } from 'node:os';
3737
import { join } from 'node:path';
@@ -86,12 +86,8 @@ function makeRes() {
8686
const dir = mkdtempSync(join(tmpdir(), 'os-cascade-rollup-'));
8787
let engine: ObjectQL;
8888
let call: (method: string, path: string, req: Record<string, unknown>) => Promise<any>;
89-
let warn: ReturnType<typeof vi.spyOn>;
90-
let errorLog: ReturnType<typeof vi.spyOn>;
9189

9290
beforeAll(async () => {
93-
warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
94-
errorLog = vi.spyOn(console, 'error').mockImplementation(() => {});
9591
engine = new ObjectQL();
9692
engine.registerDriver(
9793
new SqlDriver({ client: 'better-sqlite3', connection: { filename: join(dir, 'cascade.sqlite') }, useNullAsDefault: true }) as any,
@@ -127,14 +123,12 @@ beforeAll(async () => {
127123
});
128124

129125
afterAll(async () => {
130-
warn.mockRestore();
131-
errorLog.mockRestore();
132126
try { await engine.destroy(); } catch { /* noop */ }
133127
rmSync(dir, { recursive: true, force: true });
134128
});
135129

136130
const rowIds = async (object: string) =>
137-
((await engine.find(object, { fields: ['id'] } as any)) as Array<{ id: string }>).map((r) => r.id).sort();
131+
((await engine.find(object, { fields: ['id'] })) as Array<{ id: string }>).map((r) => r.id).sort();
138132

139133
describe('a DELETE whose cascade a dependent\'s failing roll-up stops answers a refusal', () => {
140134
it('DELETE of the account answers 500 INTERNAL_ERROR, and nothing is deleted', async () => {

0 commit comments

Comments
 (0)