Skip to content

Commit 5f529a5

Browse files
authored
Harden live assembly CLI e2e tests (#443)
* test: retry live assembly CLI e2e * test: make assembly stream check deterministic
1 parent 3cab715 commit 5f529a5

2 files changed

Lines changed: 42 additions & 37 deletions

File tree

packages/node/test/e2e/cli/assemblies-create.test.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const rreaddirAsync = promisify(rreaddir)
1919

2020
const describeLive = hasTransloaditCredentials ? describe : describe.skip
2121

22-
describeLive('assemblies', () => {
22+
describeLive('assemblies', { retry: 1 }, () => {
2323
describe('create', () => {
2424
const genericImg =
2525
'https://demos.transloadit.com/66/01604e7d0248109df8c7cc0f8daef8/snowflake.jpg'
@@ -478,41 +478,5 @@ describeLive('assemblies', () => {
478478
}),
479479
300_000,
480480
)
481-
482-
it(
483-
'should avoid opening filesystem streams during single-assembly collection',
484-
testCase(async (client) => {
485-
// Create multiple input files for single-assembly mode
486-
const fileCount = 5
487-
const infiles = await Promise.all(
488-
Array.from({ length: fileCount }, (_, i) => imgPromise(`in${i}.jpg`)),
489-
)
490-
const steps = await stepsPromise()
491-
await fsp.mkdir('out')
492-
493-
const output = new OutputCtl()
494-
await assembliesCreate(output, client, {
495-
steps,
496-
inputs: infiles,
497-
output: 'out',
498-
singleAssembly: true, // All files in one assembly
499-
})
500-
501-
// Verify files were processed
502-
const outs = await fsp.readdir('out')
503-
expect(outs.length).to.be.greaterThan(0)
504-
505-
// Analyze debug output to verify filesystem inputs were collected as file paths.
506-
// The current implementation only opens upload streams lazily for stdin inputs,
507-
// so there should be no eager "STREAM CLOSED" churn during collection.
508-
const debugOutput = output.get(true) as OutputEntry[]
509-
const messages = debugOutput.map((e) => String(e.msg))
510-
511-
const streamClosedMessages = messages.filter((m) => m.startsWith('STREAM CLOSED'))
512-
expect(streamClosedMessages).to.have.lengthOf(0)
513-
expect(messages).to.include(`Creating single assembly with ${fileCount} files`)
514-
}),
515-
300_000,
516-
)
517481
})
518482
})

packages/node/test/unit/cli/assemblies-create.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,47 @@ describe('assemblies create', () => {
319319
expect(await readFile(outputPath, 'utf8')).toBe('bundle-contents')
320320
})
321321

322+
it('collects filesystem inputs for single assemblies without opening upload streams', async () => {
323+
vi.spyOn(console, 'error').mockImplementation(() => {})
324+
325+
const tempDir = await createTempDir('transloadit-single-files-')
326+
const inputs = await Promise.all(
327+
Array.from({ length: 5 }, async (_, index) => {
328+
const inputPath = path.join(tempDir, `in${index}.txt`)
329+
await writeFile(inputPath, `input-${index}`)
330+
return inputPath
331+
}),
332+
)
333+
334+
const output = new OutputCtl()
335+
const client = {
336+
createAssembly: vi.fn().mockResolvedValue({ assembly_id: 'assembly-single-files' }),
337+
awaitAssemblyCompletion: vi.fn().mockResolvedValue({
338+
ok: 'ASSEMBLY_COMPLETED',
339+
results: {},
340+
}),
341+
}
342+
343+
await create(output, client as never, {
344+
inputs,
345+
output: null,
346+
singleAssembly: true,
347+
stepsData: {
348+
exported: {
349+
robot: '/file/filter',
350+
result: true,
351+
use: ':original',
352+
},
353+
},
354+
})
355+
356+
expect(client.createAssembly).toHaveBeenCalledTimes(1)
357+
expect(client.createAssembly.mock.calls[0]?.[0]?.files).toEqual(
358+
Object.fromEntries(inputs.map((inputPath) => [path.basename(inputPath), inputPath])),
359+
)
360+
expect(client.createAssembly.mock.calls[0]?.[0]?.uploads).toBeUndefined()
361+
})
362+
322363
it('runs valid inputless single-assembly steps instead of no-oping', async () => {
323364
vi.spyOn(console, 'error').mockImplementation(() => {})
324365

0 commit comments

Comments
 (0)