@@ -18,13 +18,13 @@ test('When we use the fastify-postgres transaction route option', async t => {
18
18
19
19
await fastify . pg . query ( 'DELETE FROM "users" WHERE TRUE' )
20
20
21
- fastify . get ( '/count-users' , async ( req , reply ) => {
21
+ fastify . get ( '/count-users' , async ( ) => {
22
22
const result = await fastify . pg . query ( 'SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'pass-opt-in\'' )
23
23
24
24
return result
25
25
} )
26
26
27
- fastify . get ( '/pass' , { pg : { transact : true } } , async ( req , reply ) => {
27
+ fastify . get ( '/pass' , { pg : { transact : true } } , async ( req ) => {
28
28
await req . pg . query ( 'INSERT INTO users(username) VALUES($1) RETURNING id' , [ 'pass-opt-in' ] )
29
29
await req . pg . query ( 'INSERT INTO users(username) VALUES($1) RETURNING id' , [ 'pass-opt-in' ] )
30
30
return 'complete'
@@ -51,13 +51,13 @@ test('When we use the fastify-postgres transaction route option', async t => {
51
51
52
52
await fastify . pg . test . query ( 'DELETE FROM "users" WHERE TRUE' )
53
53
54
- fastify . get ( '/count-users' , async ( req , reply ) => {
54
+ fastify . get ( '/count-users' , async ( ) => {
55
55
const result = await fastify . pg . test . query ( 'SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'pass-opt-in\'' )
56
56
57
57
return result
58
58
} )
59
59
60
- fastify . get ( '/pass' , { pg : { transact : 'test' } } , async ( req , reply ) => {
60
+ fastify . get ( '/pass' , { pg : { transact : 'test' } } , async ( req ) => {
61
61
await req . pg . test . query ( 'INSERT INTO users(username) VALUES($1) RETURNING id' , [ 'pass-opt-in' ] )
62
62
await req . pg . test . query ( 'INSERT INTO users(username) VALUES($1) RETURNING id' , [ 'pass-opt-in' ] )
63
63
@@ -84,7 +84,7 @@ test('When we use the fastify-postgres transaction route option', async t => {
84
84
85
85
await fastify . pg . query ( 'DELETE FROM "users" WHERE TRUE' )
86
86
87
- fastify . get ( '/count-users' , async ( req , reply ) => {
87
+ fastify . get ( '/count-users' , async ( _req , reply ) => {
88
88
const result = await fastify . pg . query ( 'SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'fail-opt-in\'' )
89
89
90
90
reply . send ( result )
@@ -119,7 +119,7 @@ test('When we use the fastify-postgres transaction route option', async t => {
119
119
120
120
await fastify . pg . test . query ( 'DELETE FROM "users" WHERE TRUE' )
121
121
122
- fastify . get ( '/count-users' , async ( req , reply ) => {
122
+ fastify . get ( '/count-users' , async ( _req , reply ) => {
123
123
const result = await fastify . pg . test . query ( 'SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'fail-opt-in\'' )
124
124
125
125
reply . send ( result )
@@ -162,7 +162,7 @@ test('When we use the fastify-postgres transaction route option', async t => {
162
162
}
163
163
} ,
164
164
pg : { transact : true }
165
- } , async ( req , reply ) => {
165
+ } , async ( ) => {
166
166
t . assert . fail ( 'should never execute the handler' )
167
167
} )
168
168
@@ -186,7 +186,7 @@ test('Should not add hooks with combinations of registration `options.name` and
186
186
await fastify . register ( fastifyPostgres , {
187
187
connectionString
188
188
} )
189
- fastify . get ( '/' , async ( req , reply ) => {
189
+ fastify . get ( '/' , async ( req ) => {
190
190
t . assert . strictEqual ( req . pg , null )
191
191
} )
192
192
await fastify . inject ( { url : '/' } )
@@ -202,7 +202,7 @@ test('Should not add hooks with combinations of registration `options.name` and
202
202
connectionString,
203
203
name : 'test'
204
204
} )
205
- fastify . get ( '/' , async ( req , reply ) => {
205
+ fastify . get ( '/' , async ( req ) => {
206
206
t . assert . strictEqual ( req . pg , null )
207
207
} )
208
208
@@ -219,7 +219,7 @@ test('Should not add hooks with combinations of registration `options.name` and
219
219
connectionString,
220
220
name : 'test'
221
221
} )
222
- fastify . get ( '/' , { pg : { transact : true } } , async ( req , reply ) => {
222
+ fastify . get ( '/' , { pg : { transact : true } } , async ( req ) => {
223
223
t . assert . strictEqual ( req . pg , null )
224
224
} )
225
225
@@ -235,7 +235,7 @@ test('Should not add hooks with combinations of registration `options.name` and
235
235
await fastify . register ( fastifyPostgres , {
236
236
connectionString
237
237
} )
238
- fastify . get ( '/' , { pg : { transact : 'test' } } , async ( req , reply ) => {
238
+ fastify . get ( '/' , { pg : { transact : 'test' } } , async ( req ) => {
239
239
t . assert . strictEqual ( req . pg , null )
240
240
} )
241
241
@@ -252,7 +252,7 @@ test('Should not add hooks with combinations of registration `options.name` and
252
252
connectionString,
253
253
name : 'test'
254
254
} )
255
- fastify . get ( '/' , { pg : { transact : 'different' } } , async ( req , reply ) => {
255
+ fastify . get ( '/' , { pg : { transact : 'different' } } , async ( req ) => {
256
256
t . assert . strictEqual ( req . pg , null )
257
257
} )
258
258
@@ -272,7 +272,7 @@ test('Should throw errors with incorrect combinations of registration `options.n
272
272
name
273
273
} )
274
274
275
- fastify . get ( '/' , { pg : { transact : name } } , async ( req , reply ) => { } )
275
+ fastify . get ( '/' , { pg : { transact : name } } , async ( ) => { } )
276
276
277
277
const response = await fastify . inject ( { url : '/' } )
278
278
t . assert . deepStrictEqual ( response . json ( ) , {
@@ -292,10 +292,10 @@ test('Should throw errors with incorrect combinations of registration `options.n
292
292
connectionString,
293
293
name
294
294
} )
295
- fastify . addHook ( 'onRequest' , async ( req , reply ) => {
295
+ fastify . addHook ( 'onRequest' , async ( req ) => {
296
296
req . pg = { [ name ] : await fastify . pg [ name ] . connect ( ) }
297
297
} )
298
- fastify . get ( '/' , { pg : { transact : name } } , async ( req , reply ) => { } )
298
+ fastify . get ( '/' , { pg : { transact : name } } , async ( ) => { } )
299
299
300
300
const response = await fastify . inject ( { url : '/' } )
301
301
t . assert . deepStrictEqual ( response . json ( ) , {
@@ -312,10 +312,10 @@ test('Should throw errors with incorrect combinations of registration `options.n
312
312
await fastify . register ( fastifyPostgres , {
313
313
connectionString
314
314
} )
315
- fastify . addHook ( 'onRequest' , async ( req , reply ) => {
315
+ fastify . addHook ( 'onRequest' , async ( req ) => {
316
316
req . pg = await fastify . pg . connect ( )
317
317
} )
318
- fastify . get ( '/' , { pg : { transact : true } } , async ( req , reply ) => { } )
318
+ fastify . get ( '/' , { pg : { transact : true } } , async ( ) => { } )
319
319
320
320
const response = await fastify . inject ( { url : '/' } )
321
321
t . assert . deepStrictEqual ( response . json ( ) , {
0 commit comments