mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
test for native to preserve an active domain
This commit is contained in:
parent
3bfc8e9b68
commit
fddf0546d0
@ -1,3 +1,4 @@
|
||||
var domain = require('domain');
|
||||
var helper = require(__dirname + "/../test-helper");
|
||||
var Client = require(__dirname + "/../../lib/native");
|
||||
|
||||
@ -14,3 +15,17 @@ test('fires callback with results', function() {
|
||||
}))
|
||||
}));
|
||||
})
|
||||
|
||||
test('preserves domain', function() {
|
||||
var dom = domain.create();
|
||||
|
||||
dom.run(function() {
|
||||
var client = new Client(helper.config);
|
||||
assert.ok(dom === require('domain').active, 'domain is active');
|
||||
client.connect()
|
||||
client.query('select 1', function() {
|
||||
assert.ok(dom === require('domain').active, 'domain is still active');
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
var helper = require(__dirname + "/../test-helper");
|
||||
var Client = require(__dirname + "/../../lib/native");
|
||||
var domain = require('domain');
|
||||
|
||||
test('connecting with wrong parameters', function() {
|
||||
var con = new Client("user=asldfkj hostaddr=127.0.0.1 port=5432 dbname=asldkfj");
|
||||
@ -20,3 +21,16 @@ test('connects', function() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('preserves domain', function() {
|
||||
var dom = domain.create();
|
||||
|
||||
dom.run(function() {
|
||||
var con = new Client(helper.config);
|
||||
assert.ok(dom === require('domain').active, 'domain is active');
|
||||
con.connect(function() {
|
||||
assert.ok(dom === require('domain').active, 'domain is still active');
|
||||
con.end();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user