Update app and tooling
This commit is contained in:
parent
3046531bdd
commit
e620ec7349
4950 changed files with 2975120 additions and 10 deletions
42
node_modules/generic-pool/test/utils.js
generated
vendored
Normal file
42
node_modules/generic-pool/test/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
"use strict";
|
||||
|
||||
const Pool = require("../lib/Pool");
|
||||
|
||||
/**
|
||||
* Generic class for handling creation of resources
|
||||
* for testing
|
||||
*/
|
||||
class ResourceFactory {
|
||||
constructor() {
|
||||
this.created = 0;
|
||||
this.destroyed = 0;
|
||||
this.bin = [];
|
||||
}
|
||||
|
||||
create() {
|
||||
return Promise.resolve({ id: this.created++ });
|
||||
}
|
||||
|
||||
validate() {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
destroy(resource) {
|
||||
this.destroyed++;
|
||||
this.bin.push(resource);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
exports.ResourceFactory = ResourceFactory;
|
||||
|
||||
/**
|
||||
* drains and terminates the pool
|
||||
*
|
||||
* @param {Pool} pool [description]
|
||||
* @return {Promise} [description]
|
||||
*/
|
||||
exports.stopPool = function(pool) {
|
||||
return pool.drain().then(function() {
|
||||
return pool.clear();
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue