mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-07-23 12:40:25 +08:00
Initial work on the server
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
var common = require('../../common');
|
||||
var assert = require('assert');
|
||||
var pool = common.createPool({
|
||||
connectionLimit : 1,
|
||||
waitForConnections : false
|
||||
});
|
||||
|
||||
pool.getConnection(function(err, connection) {
|
||||
if (err) throw err;
|
||||
pool.getConnection(function(err) {
|
||||
assert.ok(err);
|
||||
|
||||
var shouldGetConnection = false;
|
||||
pool.config.waitForConnections = true;
|
||||
pool.getConnection(function(err, connection2) {
|
||||
if (err) throw err;
|
||||
assert.ok(shouldGetConnection);
|
||||
assert.strictEqual(connection, connection2);
|
||||
|
||||
pool.end();
|
||||
});
|
||||
|
||||
shouldGetConnection = true;
|
||||
connection.end();
|
||||
});
|
||||
});
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
var common = require('../../common');
|
||||
var assert = require('assert');
|
||||
var Connection = require(common.lib + '/Connection');
|
||||
var pool = common.createPool();
|
||||
|
||||
pool.getConnection(function(err, connection) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(connection, pool._allConnections[0]);
|
||||
connection.destroy();
|
||||
|
||||
assert.ok(pool._allConnections.length == 0);
|
||||
assert.ok(connection._poolRemoved);
|
||||
assert.strictEqual(connection.end, Connection.prototype.end);
|
||||
assert.strictEqual(connection.destroy, Connection.prototype.destroy);
|
||||
|
||||
pool.end();
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
var common = require('../../common');
|
||||
var assert = require('assert');
|
||||
var pool = common.createPool();
|
||||
var poolEnded = false;
|
||||
|
||||
pool.end(function(err) {
|
||||
poolEnded = true;
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
assert(poolEnded);
|
||||
});
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
var common = require('../../common');
|
||||
var assert = require('assert');
|
||||
var Connection = require(common.lib + '/Connection');
|
||||
var pool = common.createPool();
|
||||
|
||||
pool.getConnection(function(err, connection) {
|
||||
if (err) throw err;
|
||||
assert.ok(connection instanceof Connection);
|
||||
pool.end();
|
||||
});
|
||||
Reference in New Issue
Block a user