From 6eb0cd0995c9fe281d84cca6f825fea337e090cd Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Sun, 20 Aug 2017 12:33:18 +0200 Subject: [PATCH] Added the ability to fail a streaming request in the tests (v2) --- test/v2/root.js | 4 ++-- test/v2/tests.ts/Type.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/v2/root.js b/test/v2/root.js index 3f572e87..68617d1c 100644 --- a/test/v2/root.js +++ b/test/v2/root.js @@ -71,10 +71,10 @@ module.exports = (callback, options) => { info.isValid(false, 'HTTP error.', e); }) stream.on('complete', (res, body) => { - if(res.statusCode >= 300) + if(!config.canFail && res.statusCode >= 300) return info.isValid(false, res.statusCode + ' - ' + res.statusMessage); - callback(); + callback(res, body); }) return stream; }, diff --git a/test/v2/tests.ts/Type.ts b/test/v2/tests.ts/Type.ts index 7c9efa82..f41a51ad 100644 --- a/test/v2/tests.ts/Type.ts +++ b/test/v2/tests.ts/Type.ts @@ -17,7 +17,7 @@ export interface TestInfo (config : Options, callback : (res : RequestResponse, body ?: XMLElementUtil) => void) : void (config : Options, codeStatusExpected : number, callback : (res : RequestResponse, body ?: XMLElementUtil) => void) : void } - reqStream : (config : Options, callback : () => void) => Request + reqStream : (config : Options & { canFail ?: boolean }, callback : (res : RequestResponse, body ?: string) => void) => Request } export interface TestCallback