Skip to content

Commit

Permalink
Added the ability to fail a streaming request in the tests (v2)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Aug 20, 2017
1 parent d191d72 commit 6eb0cd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/v2/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
2 changes: 1 addition & 1 deletion test/v2/tests.ts/Type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6eb0cd0

Please sign in to comment.