/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/@fastify/postgres/test/initialization-log.test.js
46 строк
1 KB
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
const { test } = require('node:test') const Fastify = require('fastify') const pg = require('pg') const fastifyPostgres = require('../index') const { connectionString } = require('./helpers') test('Initalization log tests', async (t) => { const realConsole = global.console const ctx = {} test.beforeEach(() => { ctx.fastify = require('fastify')() ctx.pg = { ...require('pg'), native: null } ctx.native = pg.native }) test.afterEach(() => { // Really would just remove the module from the // cache. ctx.pg.native = ctx.native global.console = realConsole }) await t.test('Should print warning when native module not installed', async (t) => { t.plan(2) global.console.warn = (msg) => t.assert.strictEqual(msg, "pg-native not installed, can't use native option - fallback to pg module") const fastify = Fastify() t.after(() => { fastify.close() }) await ctx.fastify.register(fastifyPostgres, { connectionString, native: true, pg: ctx.pg }) const ready = await ctx.fastify.ready() t.assert.ok(ready) }) })