Skip to content

Commit 259c2a7

Browse files
committed
test(storage): type the engine options in the refused-attach pins instead of erasing them
Claude-Session: https://claude.ai/code/session_01WYYhVJ78u7PhwFViWo1EmQ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5e7a893 commit 259c2a7

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎packages/services/service-storage/src/attachment-refused-attach-tombstone.test.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async function boot(opts: { verdict?: Verdict; master?: MasterOutcome; sharing?:
115115
};
116116
installAttachmentAccessHooks(ql as any, () => sharing, logger, undefined, () => security);
117117

118-
await ql.insert('att_parent', { id: 'p1', name: 'parent' } as any, SYS as any);
118+
await ql.insert('att_parent', { id: 'p1', name: 'parent' }, SYS);
119119
beginTransaction.mockClear();
120120
return { ql, gate, logger, beginTransaction };
121121
}
@@ -125,18 +125,18 @@ async function seedFile(ql: ObjectQL, id: string, extra: Record<string, unknown>
125125
await ql.insert('sys_file', {
126126
id, key: `attachments/${id}.bin`, name: `${id}.txt`, scope: 'attachments',
127127
status: 'committed', owner_id: UPLOADER, ...extra,
128-
} as any, SYS as any);
128+
}, SYS);
129129
}
130130

131-
const file = (ql: ObjectQL, id: string) => ql.findOne('sys_file', { where: { id }, ...SYS } as any) as Promise<any>;
132-
const joinRows = (ql: ObjectQL, id: string) => ql.find('sys_attachment', { where: { file_id: id }, ...SYS } as any);
131+
const file = (ql: ObjectQL, id: string) => ql.findOne('sys_file', { where: { id }, ...SYS }) as Promise<any>;
132+
const joinRows = (ql: ObjectQL, id: string) => ql.find('sys_attachment', { where: { file_id: id }, ...SYS });
133133

134134
/** The generic insert the `/data` create door issues for the console's attach. */
135135
const attach = (ql: ObjectQL, fileId: string, userId = UPLOADER, parentId = 'p1') =>
136136
ql.insert(
137137
'sys_attachment',
138-
{ parent_object: 'att_parent', parent_id: parentId, file_id: fileId } as any,
139-
{ context: { userId } } as any,
138+
{ parent_object: 'att_parent', parent_id: parentId, file_id: fileId },
139+
{ context: { userId } },
140140
);
141141

142142
const rejection = (p: Promise<unknown>) => p.then(() => { throw new Error('expected a refusal'); }, (e: any) => e);
@@ -245,19 +245,19 @@ describe('the tombstone is written outside the refused write\'s unit of work', (
245245
ql.transaction(async (trx: any) => {
246246
// A write the caller made in the same unit of work — the control that
247247
// the rollback is real.
248-
await ql.insert('att_parent', { id: 'p_in_tx', name: 'rolled back' } as any, { context: { ...trx, isSystem: true } } as any);
248+
await ql.insert('att_parent', { id: 'p_in_tx', name: 'rolled back' }, { context: { ...trx, isSystem: true } });
249249
return ql.insert(
250250
'sys_attachment',
251-
{ parent_object: 'att_parent', parent_id: 'p1', file_id: 'f1' } as any,
252-
{ context: { ...trx, userId: UPLOADER } } as any,
251+
{ parent_object: 'att_parent', parent_id: 'p1', file_id: 'f1' },
252+
{ context: { ...trx, userId: UPLOADER } },
253253
);
254254
}),
255255
);
256256
expect(err).toMatchObject(REFUSAL);
257257
expect(beginTransaction, 'the caller really opened a transaction').toHaveBeenCalledTimes(1);
258258

259259
expect(await runVerdict(logger, 'f1')).toBe('tombstoned');
260-
expect(await ql.findOne('att_parent', { where: { id: 'p_in_tx' }, ...SYS } as any), 'the caller\'s unit of work rolled back').toBeNull();
260+
expect(await ql.findOne('att_parent', { where: { id: 'p_in_tx' }, ...SYS }), 'the caller\'s unit of work rolled back').toBeNull();
261261
expect(await file(ql, 'f1'), 'the tombstone was not in it').toMatchObject({ status: 'deleted' });
262262
expect(logger.warn).not.toHaveBeenCalled();
263263
});
@@ -312,7 +312,7 @@ describe('controls — what this path never tombstones', () => {
312312
it('a file still attached elsewhere is not tombstoned when another attach of it is refused', async () => {
313313
const { ql, logger } = await boot({ verdict: 'deny' });
314314
await seedFile(ql, 'f1');
315-
await ql.insert('sys_attachment', { parent_object: 'att_parent', parent_id: 'p1', file_id: 'f1' } as any, SYS as any);
315+
await ql.insert('sys_attachment', { parent_object: 'att_parent', parent_id: 'p1', file_id: 'f1' }, SYS);
316316

317317
await rejection(attach(ql, 'f1'));
318318

0 commit comments

Comments
 (0)