Added conn.Close

pgx-vs-pq
Jack Christensen 2013-03-30 21:53:56 -05:00
parent 0e992bbaa5
commit bc830d4a21
2 changed files with 14 additions and 1 deletions

View File

@ -53,6 +53,14 @@ func Connect(options map[string]string) (c *conn, err error) {
return c, nil
}
func (c *conn) Close() (err error) {
buf := c.getBuf(5)
buf[0] = 'X'
binary.BigEndian.PutUint32(buf[1:], 4)
_, err = c.conn.Write(buf)
return
}
func (c *conn) rxMsg() (msg interface{}, err error) {
var t byte
var bodySize int32

View File

@ -5,8 +5,13 @@ import (
)
func TestConnect(t *testing.T) {
_, err := Connect(map[string]string{"socket": "/private/tmp/.s.PGSQL.5432"})
conn, err := Connect(map[string]string{"socket": "/private/tmp/.s.PGSQL.5432"})
if err != nil {
t.Fatal("Unable to establish connection")
}
err = conn.Close()
if err != nil {
t.Fatal("Unable to close connection")
}
}