error tests

This commit is contained in:
brianc 2011-02-24 22:06:19 -06:00
parent b7c3db5f32
commit 567446e090
3 changed files with 38 additions and 2 deletions

View File

@ -46,8 +46,8 @@ p.connect = function() {
})
}
p.query = function(config) {
var q = new NativeQuery(config);
p.query = function(config, values) {
var q = new NativeQuery(config, values);
this._queryQueue.push(q);
this._pulseQueryQueue();
return q;

View File

@ -102,6 +102,10 @@ public:
if(!args[0]->IsString()) {
return ThrowException(Exception::Error(String::New("First parameter must be a string query")));
}
printf("testing for logs","");
if(!args[1]->IsArray()) {
return ThrowException(Exception::Error(String::New("Values must be array")));
}
String::Utf8Value queryText(args[0]->ToString());
int result = self->Send(*queryText);

View File

@ -27,3 +27,35 @@ test('parameterized query with non-text as first parameter throws error', functi
})
})
var connect = function(callback) {
var client = new Client(conString);
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();
})
})
test('config', function() {
connect(function(client) {
assert.throws(function() {
client.query({
text: "SELECT *",
values: "ALSDKFJ"
})
})
client.end();
})
})
})