-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testing cases for the agentcache
- Loading branch information
1 parent
02444e3
commit 6731437
Showing
2 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const GlobalConfig = require('./../../lib/global_config'); | ||
const getProxyAgent = require('./../../lib/http/node').getProxyAgent; | ||
const getAgentCacheSize = require('./../../lib/http/node').getAgentCacheSize; | ||
const assert = require('assert'); | ||
|
||
describe('getProxtAgent', function () { | ||
const mockProxy = new URL('https://user:[email protected]:1234'); | ||
const fakeAccessUrl = new URL('http://fakeaccount.snowflakecomputing.com'); | ||
|
||
const testCases = [ | ||
{ | ||
destination: 'test.destination.com', | ||
isNewAgent: true, | ||
keepAlive: true | ||
}, | ||
{ | ||
destination: 's3.amazonaws.com', | ||
isNewAgent: true, | ||
keepAlive: true | ||
}, | ||
{ | ||
destination: 'http://test.destination.com/login/somewhere', | ||
isNewAgent: false, | ||
keepAlive: true | ||
}, | ||
{ | ||
destination: 'http://s3.amazonaws.com', | ||
isNewAgent: false, | ||
keepAlive: true | ||
}, | ||
{ | ||
destination: 'https://s3.amazonaws.com', | ||
isNewAgent: true, | ||
keepAlive: false | ||
}, | ||
{ | ||
destination: 'https://test.destination.com/login/somewhere', | ||
isNewAgent: true, | ||
keepAlive: false | ||
}, | ||
{ | ||
destination: 'https://fakeaccount.snowflakecomputing.com/login/sessionId=something', | ||
isNewAgent: true, | ||
keepAlive: true | ||
}, | ||
{ | ||
destination: 'https://fakeaccount.snowflakecomputing.com/other/request', | ||
isNewAgent: false, | ||
keepAlive: true | ||
}, | ||
{ | ||
destination: 'http://fakeaccount.snowflakecomputing.com/another/request', | ||
isNewAgent: true, | ||
keepAlive: false | ||
}, | ||
]; | ||
|
||
it('test http(s) agent cache', () => { | ||
let numofAgent = 0; | ||
testCases.forEach(({ destination, isNewAgent, keepAlive }) => { | ||
GlobalConfig.setKeepAlive(keepAlive); | ||
getProxyAgent(mockProxy, fakeAccessUrl, destination); | ||
if (isNewAgent) { | ||
numofAgent++; | ||
} | ||
assert.strictEqual(getAgentCacheSize(), numofAgent); | ||
}); | ||
}); | ||
}); | ||
|