File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -536,3 +536,35 @@ t('throws correct error when authentication fails', async() => {
536
536
} )
537
537
return [ '28P01' , await sql `select 1` . catch ( e => e . code ) ]
538
538
} )
539
+
540
+ t ( 'notice works' , async ( ) => {
541
+ let notice
542
+ const log = console . log
543
+ console . log = function ( x ) {
544
+ notice = x
545
+ }
546
+
547
+ const sql = postgres ( {
548
+ ...options
549
+ } )
550
+
551
+ await sql `create table if not exists users()`
552
+ await sql `create table if not exists users()`
553
+
554
+ console . log = log
555
+
556
+ return [ 'NOTICE' , notice . severity ]
557
+ } )
558
+
559
+ t ( 'notice hook works' , async ( ) => {
560
+ let notice
561
+ const sql = postgres ( {
562
+ ...options ,
563
+ onnotice : x => notice = x
564
+ } )
565
+
566
+ await sql `create table if not exists users()`
567
+ await sql `create table if not exists users()`
568
+
569
+ return [ 'NOTICE' , notice . severity ]
570
+ } )
You can’t perform that action at this time.
0 commit comments