mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
update to 4.0
This commit is contained in:
26
test/spec_lib/util.js
Normal file
26
test/spec_lib/util.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* test for rule replaceOption rule
|
||||
*
|
||||
*/
|
||||
const util = require('../../lib/util');
|
||||
|
||||
describe('utils', () => {
|
||||
it('should get some free ports', done => {
|
||||
const count = 100;
|
||||
const tasks = [];
|
||||
for (let i = 1; i <= count; i++) {
|
||||
tasks.push(util.getFreePort());
|
||||
}
|
||||
Promise.all(tasks)
|
||||
.then((results) => {
|
||||
// ensure ports are unique
|
||||
const portMap = {};
|
||||
results.map((portNumber) => {
|
||||
portMap[portNumber] = true;
|
||||
});
|
||||
expect(Object.keys(portMap).length).toEqual(count);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user