Skip to content

Commit bd81d51

Browse files
authored
Fix Tests random failure (#165)
1 parent f9af012 commit bd81d51

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function fastifyPostgres (fastify, options, next) {
161161
}
162162
}
163163

164-
client.query('BEGIN')
164+
await client.query('BEGIN')
165165
}
166166

167167
const onError = (req, reply, error, done) => {

test/req-initialization.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('When we use the fastify-postgres transaction route option', t => {
1616
connectionString
1717
})
1818

19-
await fastify.pg.query('TRUNCATE users')
19+
await fastify.pg.query('DELETE FROM "users" WHERE TRUE')
2020

2121
fastify.get('/count-users', async (req, reply) => {
2222
const result = await fastify.pg.query('SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'pass-opt-in\'')
@@ -49,7 +49,7 @@ test('When we use the fastify-postgres transaction route option', t => {
4949
name: 'test'
5050
})
5151

52-
await fastify.pg.test.query('TRUNCATE users')
52+
await fastify.pg.test.query('DELETE FROM "users" WHERE TRUE')
5353

5454
fastify.get('/count-users', async (req, reply) => {
5555
const result = await fastify.pg.test.query('SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'pass-opt-in\'')
@@ -82,7 +82,7 @@ test('When we use the fastify-postgres transaction route option', t => {
8282
connectionString
8383
})
8484

85-
await fastify.pg.query('TRUNCATE users')
85+
await fastify.pg.query('DELETE FROM "users" WHERE TRUE')
8686

8787
fastify.get('/count-users', async (req, reply) => {
8888
const result = await fastify.pg.query('SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'fail-opt-in\'')
@@ -117,7 +117,7 @@ test('When we use the fastify-postgres transaction route option', t => {
117117
name: 'test'
118118
})
119119

120-
await fastify.pg.test.query('TRUNCATE users')
120+
await fastify.pg.test.query('DELETE FROM "users" WHERE TRUE')
121121

122122
fastify.get('/count-users', async (req, reply) => {
123123
const result = await fastify.pg.test.query('SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'fail-opt-in\'')

0 commit comments

Comments
 (0)