Created
June 4, 2018 10:55
-
-
Save HugoPoi/ef4ce3d6be3e421768265333b301f248 to your computer and use it in GitHub Desktop.
Test concurrent calls with an agentClass ( mocha runner )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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