test('support works standalone', async (t) => { const fastify = Fastify() fastify.register(Support) await fastify.ready() t.equal(fastify.someSupport(), 'here support') })
test('support works standalone', (t) => { t.plan(2) const fastify = Fastify() fastify.register(Support) fastify.ready((err) => { t.error(err) t.equal(fastify.someSupport(), 'hugs') }) })
fastify.register(fsequelize, { instance: 'db', // name of instance will be mapped to fastify dialect: 'sqlite', // SQLite only storage: resolve(__dirname, 'db.sqlite') }) .ready(() => { // Test connection fastify.db .authenticate() .then(() => { console.log('Connection has been established successfully.'); }) .catch(err => { console.error('Unable to connect to the database:', err); }); })
app.ready(() => app.swagger())
test('fastify.sequelize should exist', t => { t.plan(2) const fastify = Fastify() fastify.register(fastifySequelize, { dialect: 'sqlite', storage: resolve(__dirname, 'db.sqlite') }) fastify.ready(err => { t.error(err) t.ok(fastify.sequelize) fastify.sequelize.close() fastify.close() }) })
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('gun should support gundb operations', t => { t.plan(2) const fastify = Fastify() fastify .register(gunPlugin, { name: 'test' }) .ready(err => { t.error(err) fastify.gun.get('test').set('d').once(function (val) { if (!val) t.error('no data') t.equal('d', val) }) }) })
}) fastify.ready(err => { t.error(err) t.ok(fastify.sequelize)
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) }); }) }) })
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() }) })
test('support works standalone', async (t) => { const fastify = Fastify() fastify.register(Support) await fastify.ready() t.equal(fastify.someSupport(), 'here support') })