feat: publish av-tools 0.2.0
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import {
|
||||
DEFAULT_JOB_TIMEOUT_MILLISECONDS,
|
||||
EngineManager,
|
||||
MAX_CONTACT_SHEETS_PER_ENGINE,
|
||||
MAX_EXECUTIONS_PER_ENGINE,
|
||||
MAX_PROBE_TIMEOUT_MILLISECONDS,
|
||||
MIN_PROBE_TIMEOUT_MILLISECONDS,
|
||||
MULTITHREAD_CODEC_THREAD_LIMIT,
|
||||
engineJobTimeoutMilliseconds,
|
||||
prepareEngineArguments,
|
||||
probeTimeoutMilliseconds,
|
||||
shouldRecycleExecutionCore,
|
||||
} from '../../src/ffmpeg/EngineManager';
|
||||
|
||||
@@ -90,6 +94,39 @@ describe('engineJobTimeoutMilliseconds', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('probeTimeoutMilliseconds', () => {
|
||||
it('keeps small probes responsive, scales real media, and caps the watchdog', () => {
|
||||
expect(probeTimeoutMilliseconds(34_057)).toBe(
|
||||
MIN_PROBE_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
expect(probeTimeoutMilliseconds(153_019_068)).toBe(72_966);
|
||||
expect(probeTimeoutMilliseconds(2 * 1024 * 1024 * 1024)).toBe(
|
||||
MAX_PROBE_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects an already-cancelled probe before loading an engine', async () => {
|
||||
const factory = vi.fn(async () => {
|
||||
throw new Error('The engine factory must not be called.');
|
||||
});
|
||||
const manager = new EngineManager(factory);
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
|
||||
await expect(
|
||||
manager.probe(
|
||||
new File(['media'], 'cancelled.mp4', { type: 'video/mp4' }),
|
||||
undefined,
|
||||
controller.signal
|
||||
)
|
||||
).rejects.toMatchObject({
|
||||
code: 'cancelled',
|
||||
message: 'The media probe was cancelled.',
|
||||
});
|
||||
expect(factory).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('execution core recycling policy', () => {
|
||||
it('refreshes only after the bounded idle-core job budget is exhausted', () => {
|
||||
expect(shouldRecycleExecutionCore(MAX_EXECUTIONS_PER_ENGINE - 1)).toBe(
|
||||
|
||||
Reference in New Issue
Block a user