Skip to content

Commit 7bbd1f9

Browse files
committed
Test notice
1 parent b83c2f6 commit 7bbd1f9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/index.js

+32
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,35 @@ t('throws correct error when authentication fails', async() => {
536536
})
537537
return ['28P01', await sql`select 1`.catch(e => e.code)]
538538
})
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+
})

0 commit comments

Comments
 (0)