@@ -6,20 +6,22 @@ const Fastify = require('fastify')
66const fastifyPostgres = require ( './index' )
77
88test ( 'fastify.pg namespace should exist' , t => {
9- t . plan ( 5 )
9+ t . plan ( 6 )
1010
1111 const fastify = Fastify ( )
1212
1313 fastify . register ( fastifyPostgres , {
14+ name : 'test' ,
1415 connectionString : 'postgres://postgres@localhost/postgres'
1516 } )
1617
1718 fastify . ready ( err => {
1819 t . error ( err )
1920 t . ok ( fastify . pg )
20- t . ok ( fastify . pg . connect )
21- t . ok ( fastify . pg . pool )
22- t . ok ( fastify . pg . Client )
21+ t . ok ( fastify . pg . test )
22+ t . ok ( fastify . pg . test . connect )
23+ t . ok ( fastify . pg . test . pool )
24+ t . ok ( fastify . pg . test . Client )
2325 fastify . close ( )
2426 } )
2527} )
@@ -30,12 +32,13 @@ test('should be able to connect and perform a query', t => {
3032 const fastify = Fastify ( )
3133
3234 fastify . register ( fastifyPostgres , {
35+ name : 'test' ,
3336 connectionString : 'postgres://postgres@localhost/postgres'
3437 } )
3538
3639 fastify . ready ( err => {
3740 t . error ( err )
38- fastify . pg . connect ( onConnect )
41+ fastify . pg . test . connect ( onConnect )
3942 } )
4043
4144 function onConnect ( err , client , done ) {
@@ -55,12 +58,13 @@ test('use query util', t => {
5558 const fastify = Fastify ( )
5659
5760 fastify . register ( fastifyPostgres , {
61+ name : 'test' ,
5862 connectionString : 'postgres://postgres@localhost/postgres'
5963 } )
6064
6165 fastify . ready ( err => {
6266 t . error ( err )
63- fastify . pg . query ( 'SELECT NOW()' , ( err , result ) => {
67+ fastify . pg . test . query ( 'SELECT NOW()' , ( err , result ) => {
6468 t . error ( err )
6569 t . ok ( result . rows )
6670 fastify . close ( )
@@ -74,12 +78,13 @@ test('use query util with promises', t => {
7478 const fastify = Fastify ( )
7579
7680 fastify . register ( fastifyPostgres , {
81+ name : 'test' ,
7782 connectionString : 'postgres://postgres@localhost/postgres'
7883 } )
7984
8085 fastify . ready ( err => {
8186 t . error ( err )
82- fastify . pg
87+ fastify . pg . test
8388 . query ( 'SELECT NOW()' )
8489 . then ( result => {
8590 t . ok ( result . rows )
@@ -98,13 +103,14 @@ test('use native module', t => {
98103 const fastify = Fastify ( )
99104
100105 fastify . register ( fastifyPostgres , {
106+ name : 'test' ,
101107 connectionString : 'postgres://postgres@localhost/postgres' ,
102108 native : true
103109 } )
104110
105111 fastify . ready ( err => {
106112 t . error ( err )
107- fastify . pg
113+ fastify . pg . test
108114 . query ( 'SELECT 1 AS one' )
109115 . then ( result => {
110116 t . ok ( result . rows [ 0 ] . one === 1 )
0 commit comments