Skip to content

Commit c26b15c

Browse files
committed
test(service-storage): seed an org-less session with null, not undefined
An undefined argument takes the seed helper's default and stamped the session org_a, so the org-less-session pins pinned nothing. Each now asserts its premise. Claude-Session: https://claude.ai/code/session_01WkL6Eijt432S1Y7ekb6ovQ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3be6d50 commit c26b15c

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎packages/services/service-storage/src/storage-routes.metadata-outage.test.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,13 @@ describe('Storage routes: an organization change is not an outage (#22175)', ()
332332
* A pending upload Alice started in `org_a`: its file row and, for the
333333
* chunked door, its session — opened on the real adapter, so a completion
334334
* that gets past the doors' questions really assembles. Sets {@link uploadId}.
335+
*
336+
* `null` seeds the session with NO organization. Not `undefined`: an
337+
* `undefined` argument takes the parameter's default, so it would seed
338+
* `org_a` and a pin about an org-less session would pin nothing.
335339
*/
336340
let uploadId: string;
337-
const seed = async (store: StorageMetadataStore, sessionOrganization: string | undefined = 'org_a') => {
341+
const seed = async (store: StorageMetadataStore, sessionOrganization: string | null = 'org_a') => {
338342
uploadId = await adapter.initiateChunkedUpload('user/f1.bin', { contentType: 'application/octet-stream' });
339343
await store.createFile({
340344
id: 'f1',
@@ -353,7 +357,7 @@ describe('Storage routes: an organization change is not an outage (#22175)', ()
353357
chunk_size: 50,
354358
total_chunks: 2,
355359
status: 'in_progress',
356-
...(sessionOrganization ? { organization_id: sessionOrganization } : {}),
360+
...(sessionOrganization !== null ? { organization_id: sessionOrganization } : {}),
357361
});
358362
};
359363
const expectOrganizationChanged = (res: ReturnType<typeof createMockRes>, label: string) => {
@@ -466,7 +470,8 @@ describe('Storage routes: an organization change is not an outage (#22175)', ()
466470

467471
it('a session row with no organization still answers 409 when its FILE row is out of reach — that write would miss', async () => {
468472
const engine = createFakeEngine();
469-
await seed(mount(engine), undefined);
473+
await seed(mount(engine), null);
474+
expect(engine._rows('sys_upload_session')[0].organization_id).toBeUndefined();
470475
const res = await drive('POST', CHUNKED_COMPLETE, 'alice@b', { params: { uploadId }, body: { parts: [] } });
471476
expectOrganizationChanged(res, 'org-less session, file in org_a');
472477
expect(engine._rows('sys_upload_session')[0]).toMatchObject({ status: 'in_progress' });
@@ -577,7 +582,8 @@ describe('Storage routes: an organization change is not an outage (#22175)', ()
577582

578583
it('UNCHANGED — a session row with no organization stays in reach: this door writes no file row', async () => {
579584
const engine = createFakeEngine();
580-
await seed(mount(engine), undefined);
585+
await seed(mount(engine), null);
586+
expect(engine._rows('sys_upload_session')[0].organization_id).toBeUndefined();
581587
expect((await sendChunk('alice@b'))._status).toBe(200);
582588
expect(engine._rows('sys_upload_session')[0]).toMatchObject({ uploaded_chunks: 1 });
583589
});
@@ -653,7 +659,8 @@ describe('Storage routes: an organization change is not an outage (#22175)', ()
653659
it('UNCHANGED — a session row with no organization stays in reach: stamped `expired` from any organization', async () => {
654660
const engine = createFakeEngine();
655661
const store = mount(engine);
656-
await seed(store, undefined);
662+
await seed(store, null);
663+
expect(engine._rows('sys_upload_session')[0].organization_id).toBeUndefined();
657664
await pastDeadline(store);
658665
const res = await drive('GET', PROGRESS, 'alice@b', { params: { uploadId } });
659666
expect(res._status).toBe(200);

0 commit comments

Comments
 (0)