Skip to content

Commit

Permalink
Fix Tests random failure (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaRainone authored Oct 18, 2023
1 parent f9af012 commit bd81d51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function fastifyPostgres (fastify, options, next) {
}
}

client.query('BEGIN')
await client.query('BEGIN')
}

const onError = (req, reply, error, done) => {
Expand Down
8 changes: 4 additions & 4 deletions test/req-initialization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('When we use the fastify-postgres transaction route option', t => {
connectionString
})

await fastify.pg.query('TRUNCATE users')
await fastify.pg.query('DELETE FROM "users" WHERE TRUE')

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

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

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

await fastify.pg.query('TRUNCATE users')
await fastify.pg.query('DELETE FROM "users" WHERE TRUE')

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

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

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

0 comments on commit bd81d51

Please sign in to comment.