node-postgres/test/native/error-tests.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

var helper = require(__dirname + "/../test-helper");
var Client = require(__dirname + "/../../lib/native");
test('query with non-text as first parameter throws error', function() {
var client = new Client(helper.config);
client.connect();
assert.emits(client, 'connect', function() {
2011-02-25 11:50:17 +08:00
assert.throws(function() {
client.query({text:{fail: true}});
2011-02-25 11:50:17 +08:00
})
client.end();
})
})
2011-02-25 11:50:17 +08:00
test('parameterized query with non-text as first parameter throws error', function() {
var client = new Client(helper.config);
2011-02-25 11:50:17 +08:00
client.connect();
assert.emits(client, 'connect', function() {
assert.throws(function() {
client.query({
text: {fail: true},
values: [1, 2]
})
})
client.end();
})
})
2011-02-25 12:06:19 +08:00
var connect = function(callback) {
var client = new Client(helper.config);
2011-02-25 12:06:19 +08:00
client.connect();
assert.emits(client, 'connect', function() {
callback(client);
})
}
test('parameterized query with non-array for second value', function() {
test('inline', function() {
connect(function(client) {
assert.throws(function() {
client.query("SELECT *", "LKSDJF")
})
client.end();
})
})
2011-02-25 12:09:36 +08:00
test('config', function() {
2011-02-25 12:06:19 +08:00
connect(function(client) {
assert.throws(function() {
client.query({
text: "SELECT *",
values: "ALSDKFJ"
})
})
client.end();
})
})
})