function build (t) { const app = Fastify() app.register(fp(App), config()) t.tearDown(app.close.bind(app)) return app }
test('gun namespace should exist', t => { t.plan(3) const fastify = Fastify() fastify .register(gunPlugin, { name: 'test' }) .ready(err => { t.error(err) t.ok(fastify.gun) fastify.close(() => { t.pass('unlock') }) }) })
test('Sequelize instance name should work', t => { t.plan(2) const fastify = Fastify() fastify.register(fastifySequelize, { instance: 'db', // instance name dialect: 'sqlite', storage: resolve(__dirname, 'db.sqlite') }) fastify.ready(err => { t.error(err) t.ok(fastify.db) // instance name fastify.db.close() fastify.close() }) })
t.strictEqual(result, '{"hello":"world"}', 'got correct body') agent.flush() fastify.close() t.end() })
afterAll(() => { fastify.close(); });
}, 'got correct body') agent.flush() fastify.close() t.end() })
t.strictEqual(result, '{"hello":"world"}', 'got correct body') agent.flush() fastify.close() t.end() })
test('Sequelize should close connection before Fastify closed', t => { t.plan(2) const fastify = Fastify() fastify.register(fastifySequelize, { dialect: 'sqlite', storage: resolve(__dirname, 'db.sqlite') }) fastify.ready(err => { t.error(err) fastify.close(() => { fastify .sequelize .authenticate() .then(() => { t.error('connection not closed !') }) .catch(err => { t.ok(err) }); }) }) })
function build (t) { const app = Fastify() app.register(fp(App), config()) t.tearDown(app.close.bind(app)) return app }
// automatically build and tear down our instance function build (t) { const app = Fastify() // fastify-plugin ensures that all decorators // are exposed for testing purposes, this is // different from the production setup app.register(fp(App), config()) // tear down our app after we are done t.tearDown(app.close.bind(app)) return app }