mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add timeout function to limit processing time
This commit is contained in:
26
test/unit/timeout.js
Normal file
26
test/unit/timeout.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
const sharp = require('../../');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
describe('Timeout', function () {
|
||||
it('Will timeout after 1s when performing slow blur operation', () => assert.rejects(
|
||||
() => sharp(fixtures.inputJpg)
|
||||
.blur(100)
|
||||
.timeout({ seconds: 1 })
|
||||
.toBuffer(),
|
||||
/timeout: [0-9]+% complete/
|
||||
));
|
||||
|
||||
it('invalid object', () => assert.throws(
|
||||
() => sharp().timeout('fail'),
|
||||
/Expected object for options but received fail of type string/
|
||||
));
|
||||
|
||||
it('invalid seconds', () => assert.throws(
|
||||
() => sharp().timeout({ seconds: 'fail' }),
|
||||
/Expected integer between 0 and 3600 for seconds but received fail of type string/
|
||||
));
|
||||
});
|
||||
Reference in New Issue
Block a user