test for native to preserve an active domain

This commit is contained in:
Andrey Popp 2013-05-20 18:03:54 +04:00
parent 3bfc8e9b68
commit fddf0546d0
2 changed files with 29 additions and 0 deletions

View File

@ -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();
});
});
})

View File

@ -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();
});
});
})