Skip to content

Instantly share code, notes, and snippets.

@HugoPoi
Created June 4, 2018 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HugoPoi/ef4ce3d6be3e421768265333b301f248 to your computer and use it in GitHub Desktop.
Save HugoPoi/ef4ce3d6be3e421768265333b301f248 to your computer and use it in GitHub Desktop.
Test concurrent calls with an agentClass ( mocha runner )
/*jshint node: true*/
"use strict";
process.env.NODE_ENV = 'test';
const assert = require('assert');
const Request = require('request-promise');
const HttpsAgent = require('socks5-https-client/lib/Agent');
const Promise = require('bluebird');
describe('Request', function() {
describe('Test concurrency with agentClass vs agent options', function(){
it('with agentClass option', function(){
return Promise.all([Request({
url: 'https://ipinfo.io/',
json: true,
agentClass: HttpsAgent,
agentOptions: {
socksHost: 'localhost',
socksPort: 9050
}
}),
Request({
url: 'https://ipinfo.io/',
json: true,
agentClass: HttpsAgent,
agentOptions: {
socksHost: 'localhost',
socksPort: 9051
}
})
]).then(results => console.log(results));
});
it('with agent option', function(){
return Promise.all([Request({
url: 'https://ipinfo.io/',
json: true,
agent: new HttpsAgent({
socksHost: 'localhost',
socksPort: 9050
})
}),
Request({
url: 'https://ipinfo.io/',
json: true,
agent: new HttpsAgent({
socksHost: 'localhost',
socksPort: 9051
})
})
]).then(results => console.log(results));
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment