Add client connectionString tests (#1310)
* Remove redundant tests * Add client connectionString test Add test to ensure { connectionString } is respected as an argument to the client constructor * Add test for connection string property Also fixed some legacy require statements.
This commit is contained in:
parent
3757ff7300
commit
f2b87e02f1
@ -3,7 +3,6 @@ var util = require('util');
|
||||
var Pool = require('pg-pool');
|
||||
|
||||
module.exports = function(Client) {
|
||||
|
||||
var BoundPool = function(options) {
|
||||
var config = { Client: Client };
|
||||
for (var key in options) {
|
||||
|
@ -1,2 +1,2 @@
|
||||
var helper = require(__dirname + "/test-helper")
|
||||
var helper = require("./test-helper")
|
||||
helper.testPoolSize(2);
|
||||
|
@ -1,4 +1,4 @@
|
||||
var helper = require(__dirname + '/test-helper')
|
||||
var helper = require('./test-helper')
|
||||
|
||||
var called = false;
|
||||
test('disconnects', function() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
var helper = require(__dirname + '/test-helper')
|
||||
var helper = require('./test-helper')
|
||||
|
||||
var called = false;
|
||||
|
||||
test('disconnects', function() {
|
||||
var sink = new helper.Sink(4, function() {
|
||||
called = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
var helper = require(__dirname + "/../test-helper");
|
||||
var pg = require(__dirname + "/../../../lib");
|
||||
var helper = require("../test-helper");
|
||||
var pg = require("../../../lib");
|
||||
|
||||
//first make pool hold 2 clients
|
||||
pg.defaults.poolSize = 2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
var helper = require(__dirname + '/test-helper');
|
||||
var helper = require('./test-helper');
|
||||
var _ = require('lodash')
|
||||
|
||||
const config = _.extend({ }, helper.config, { idleTimeoutMillis: 50 })
|
||||
|
@ -1,2 +1,2 @@
|
||||
var helper = require(__dirname + "/test-helper")
|
||||
var helper = require("./test-helper")
|
||||
helper.testPoolSize(40);
|
||||
|
@ -1,4 +1,4 @@
|
||||
var helper = require(__dirname + "/../test-helper")
|
||||
var helper = require("./../test-helper")
|
||||
var pg = helper.pg
|
||||
var native = helper.args.native
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
var helper = require(__dirname + '/test-helper');
|
||||
var helper = require('./test-helper');
|
||||
|
||||
//setup defaults
|
||||
helper.pg.defaults.user = helper.args.user;
|
||||
|
@ -1,2 +1,2 @@
|
||||
var helper = require(__dirname + "/test-helper")
|
||||
var helper = require("./test-helper")
|
||||
helper.testPoolSize(1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
var helper = require(__dirname + "/../test-helper");
|
||||
var pg = require(__dirname + "/../../../lib");
|
||||
var helper = require("../test-helper");
|
||||
var pg = require("../../../lib");
|
||||
|
||||
pg.connect(helper.config, assert.success(function(client, done) {
|
||||
assert.equal(Object.keys(pg._pools).length, 1);
|
||||
|
@ -1,2 +1,2 @@
|
||||
var helper = require(__dirname + "/test-helper")
|
||||
var helper = require("./test-helper")
|
||||
helper.testPoolSize(200);
|
||||
|
@ -59,6 +59,17 @@ test('client settings', function() {
|
||||
|
||||
test('initializing from a config string', function() {
|
||||
|
||||
test('uses connectionString property', function () {
|
||||
var client = new Client({
|
||||
connectionString: 'postgres://brian:pass@host1:333/databasename'
|
||||
})
|
||||
assert.equal(client.user, 'brian');
|
||||
assert.equal(client.password, "pass");
|
||||
assert.equal(client.host, "host1");
|
||||
assert.equal(client.port, 333);
|
||||
assert.equal(client.database, "databasename");
|
||||
})
|
||||
|
||||
test('uses the correct values from the config string', function() {
|
||||
var client = new Client("postgres://brian:pass@host1:333/databasename")
|
||||
assert.equal(client.user, 'brian');
|
||||
|
@ -1,27 +0,0 @@
|
||||
require(__dirname + '/test-helper');
|
||||
|
||||
/*
|
||||
* Perhaps duplicate of test named 'initializing from a config string' in
|
||||
* configuration-tests.js
|
||||
*/
|
||||
|
||||
test("using connection string in client constructor", function() {
|
||||
var client = new Client("postgres://brian:pw@boom:381/lala");
|
||||
|
||||
test("parses user", function() {
|
||||
assert.equal(client.user,'brian');
|
||||
});
|
||||
test("parses password", function() {
|
||||
assert.equal(client.password, 'pw');
|
||||
});
|
||||
test("parses host", function() {
|
||||
assert.equal(client.host, 'boom');
|
||||
});
|
||||
test('parses port', function() {
|
||||
assert.equal(client.port, 381)
|
||||
});
|
||||
test('parses database', function() {
|
||||
assert.equal(client.database, 'lala')
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user