mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
connection termination
This commit is contained in:
parent
93c1135389
commit
67e56fe832
@ -35,6 +35,7 @@ public:
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "_sendQuery", SendQuery);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "end", End);
|
||||
|
||||
target->Set(String::NewSymbol("Connection"), t->GetFunction());
|
||||
LOG("created class");
|
||||
@ -83,6 +84,15 @@ public:
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
static Handle<Value>
|
||||
End(const Arguments& args)
|
||||
{
|
||||
HandleScope scope;
|
||||
Connection *self = ObjectWrap::Unwrap<Connection>(args.This());
|
||||
|
||||
self->End();
|
||||
}
|
||||
|
||||
ev_io read_watcher_;
|
||||
ev_io write_watcher_;
|
||||
PGconn *connection_;
|
||||
@ -257,6 +267,11 @@ protected:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void End()
|
||||
{
|
||||
PQfinish(connection_);
|
||||
}
|
||||
|
||||
private:
|
||||
void HandleConnectionIO()
|
||||
|
||||
@ -17,6 +17,7 @@ test('connecting with wrong parameters', function() {
|
||||
con.connect("user=asldfkj hostaddr=127.0.0.1 port=5432 dbname=asldkfj");
|
||||
assert.emits(con, 'error', function(error) {
|
||||
console.log(error);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
@ -26,5 +27,8 @@ test('connects', function() {
|
||||
con.connect("user=brian hostaddr=127.0.0.1 port=5432 dbname=postgres");
|
||||
assert.emits(con, 'connect', function() {
|
||||
con._sendQuery("SELECT NOW()");
|
||||
test('ends connection', function() {
|
||||
con.end();
|
||||
})
|
||||
});
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user