node-postgres/test/integration/gh-issues/981-tests.js
Brian C a8bd44a6ec Requiring native bindings polutes 'global' (#984)
There was some nasty global-ish variable reference updating happening when the native module 'initializes' after its require with `require('pg').native`

This fixes the issue by making sure both `require('pg')` and `require('pg').native` each initialize their own context in isolation and no weird global-ish references are used & subsequently stomped on.
2016-04-08 18:46:10 -05:00

28 lines
642 B
JavaScript

var helper = require(__dirname + '/../test-helper');
//native bindings are only installed for native tests
if(!helper.args.native) {
return;
}
var assert = require('assert')
var pg = require('../../../lib')
var native = require('../../../lib').native
var JsClient = require('../../../lib/client')
var NativeClient = require('../../../lib/native')
assert(pg.Client === JsClient);
assert(native.Client === NativeClient);
pg.connect(function(err, client, done) {
assert(client instanceof JsClient);
client.end();
native.connect(function(err, client, done) {
assert(client instanceof NativeClient);
client.end();
});
});