error test
This commit is contained in:
parent
f4ca716b93
commit
b7c3db5f32
@ -99,7 +99,13 @@ public:
|
|||||||
{
|
{
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
Connection *self = ObjectWrap::Unwrap<Connection>(args.This());
|
Connection *self = ObjectWrap::Unwrap<Connection>(args.This());
|
||||||
printf("%d\n", args.Length());
|
if(!args[0]->IsString()) {
|
||||||
|
return ThrowException(Exception::Error(String::New("First parameter must be a string query")));
|
||||||
|
}
|
||||||
|
|
||||||
|
String::Utf8Value queryText(args[0]->ToString());
|
||||||
|
int result = self->Send(*queryText);
|
||||||
|
|
||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,13 +6,24 @@ test('query with non-text as first parameter throws error', function() {
|
|||||||
var client = new Client(conString);
|
var client = new Client(conString);
|
||||||
client.connect();
|
client.connect();
|
||||||
assert.emits(client, 'connect', function() {
|
assert.emits(client, 'connect', function() {
|
||||||
var err;
|
assert.throws(function() {
|
||||||
try{
|
|
||||||
client.query({text:{fail: true}});
|
client.query({text:{fail: true}});
|
||||||
} catch(e) {
|
})
|
||||||
err = e;
|
|
||||||
}
|
|
||||||
assert.ok(err != null, "Expected exception to be thrown")
|
|
||||||
client.end();
|
client.end();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('parameterized query with non-text as first parameter throws error', function() {
|
||||||
|
var client = new Client(conString);
|
||||||
|
client.connect();
|
||||||
|
assert.emits(client, 'connect', function() {
|
||||||
|
assert.throws(function() {
|
||||||
|
client.query({
|
||||||
|
text: {fail: true},
|
||||||
|
values: [1, 2]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
client.end();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
@ -100,6 +100,14 @@ assert.success = function(callback) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.throws = function(offender) {
|
||||||
|
try {
|
||||||
|
offender();
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assert.ok(false, "Expected " + offender + " to throw exception");
|
||||||
|
}
|
||||||
|
|
||||||
assert.length = function(actual, expectedLength) {
|
assert.length = function(actual, expectedLength) {
|
||||||
assert.equal(actual.length, expectedLength);
|
assert.equal(actual.length, expectedLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user