Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import assert from 'node:assert/strict';
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { describe, test } from 'node:test';
import { resolveIngestItems } from '../attachment-ingest.js';
import { resolveAttachmentRefs, resolveIngestItems } from '../attachment-ingest.js';
import { createAttachmentApprovalRegistry } from '../attachment-approval.js';

describe('resolveIngestItems (pre-read validation)', () => {
Expand Down Expand Up @@ -211,3 +214,28 @@ describe('resolveIngestItems (pre-read validation)', () => {
);
});
});

describe('resolveAttachmentRefs', () => {
test('rejects a path grown beyond the cap before creating a Host artifact', async () => {
const dir = await mkdtemp(join(tmpdir(), 'att-cap-'));
const path = join(dir, 'grew.bin');
await writeFile(path, Buffer.alloc(11));
let snapshots = 0;
try {
await assert.rejects(
resolveAttachmentRefs({
files: [{ path, mimeType: 'application/octet-stream', size: 5 }],
maxBytes: 10,
snapshot: async () => {
snapshots += 1;
throw new Error('snapshot must not run');
},
}),
/超出大小限制/,
);
assert.equal(snapshots, 0);
} finally {
await rm(dir, { recursive: true, force: true });
}
});
});
68 changes: 0 additions & 68 deletions apps/desktop/src/main/__tests__/attachment-ingest.test.ts

This file was deleted.

Loading
Loading