File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -48,3 +48,46 @@ test('should be able to connect and perform a query', t => {
4848 } )
4949 }
5050} )
51+
52+ test ( 'use query util' , t => {
53+ t . plan ( 3 )
54+
55+ const fastify = Fastify ( )
56+
57+ fastify . register ( fastifyPostgres , {
58+ connectionString : 'postgres://postgres@localhost/postgres'
59+ } )
60+
61+ fastify . ready ( err => {
62+ t . error ( err )
63+ fastify . pg . query ( 'SELECT NOW()' , ( err , result ) => {
64+ t . error ( err )
65+ t . ok ( result . rows )
66+ fastify . close ( )
67+ } )
68+ } )
69+ } )
70+
71+ test ( 'use query util with promises' , t => {
72+ t . plan ( 2 )
73+
74+ const fastify = Fastify ( )
75+
76+ fastify . register ( fastifyPostgres , {
77+ connectionString : 'postgres://postgres@localhost/postgres'
78+ } )
79+
80+ fastify . ready ( err => {
81+ t . error ( err )
82+ fastify . pg
83+ . query ( 'SELECT NOW()' )
84+ . then ( result => {
85+ t . ok ( result . rows )
86+ fastify . close ( )
87+ } )
88+ . catch ( err => {
89+ t . fail ( err )
90+ fastify . close ( )
91+ } )
92+ } )
93+ } )
You can’t perform that action at this time.
0 commit comments