Skip to content

Commit

Permalink
fix: Handle both no tests existing, and no remaining tests to call
Browse files Browse the repository at this point in the history
The loop which handles sending off HTTP requests for test cases can have
nothing to do under two distinct conditions:

- there are no tests at all
- all test cases have HTTP requests in flight

#190 handled only the first
of these, but broke on the second case, causing most test runs to fail.

This adds support for both cases so that graceful handling of empty test
directories works, but so does actually running a test suite.
  • Loading branch information
orangejulius committed May 5, 2020
1 parent 3c3d447 commit 0f1de9e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/request_urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ function request_urls(config, urls, callback) {
var delay = test_interval.getBackoff();

var getOneUrl = function (){
if( urls.length === 0 ){
// check if all responses have been recieved and call the next step in
// processing via the `callback` function
if( Object.keys(responses).length === total_length ){
clearInterval(intervalId);
return callback([]);
return callback( responses );
}

var url = urls.pop();

// if there are no more URLs to send requests for, we might
// be waiting for some to finish, so just return and the next call to
// this function from the ExponentialBackoff manager will try again
if (!url) {
return;
}

const agent = (url.startsWith('https:')) ? httpsAgent : httpAgent;

var requestOpts = {
Expand Down

0 comments on commit 0f1de9e

Please sign in to comment.