Skip to content

Commit 30d07b7

Browse files
committed
Updated test
1 parent 2248962 commit 30d07b7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
})

0 commit comments

Comments
 (0)