diff --git a/packages/verrou/tests/drivers/database.spec.ts b/packages/verrou/tests/drivers/database.spec.ts new file mode 100644 index 0000000..f7747e2 --- /dev/null +++ b/packages/verrou/tests/drivers/database.spec.ts @@ -0,0 +1,27 @@ +import knex from 'knex' +import { test } from '@japa/runner' + +import { DatabaseStore } from '../../src/drivers/database.js' +import { configureDatabaseGroupHooks } from '../../test_helpers/index.js' + +const db = knex({ client: 'pg', connection: { user: 'postgres', password: 'postgres' } }) +test.group('Database Driver', (group) => { + configureDatabaseGroupHooks(db, group) + + test('create table with specified tableName', async ({ assert, cleanup }) => { + const store = new DatabaseStore({ + connection: db, + dialect: 'pg', + tableName: 'verrou_my_locks', + }) + + cleanup(async () => { + await db.schema.dropTable('verrou_my_locks') + }) + + await store.save('foo', 'bar') + + const locks = await db.table('verrou_my_locks').select('*') + assert.lengthOf(locks, 1) + }) +}) diff --git a/packages/verrou/tests/drivers/postgres.spec.ts b/packages/verrou/tests/drivers/postgres.spec.ts index 84a96a2..1d23932 100644 --- a/packages/verrou/tests/drivers/postgres.spec.ts +++ b/packages/verrou/tests/drivers/postgres.spec.ts @@ -12,27 +12,9 @@ const db = knex({ test.group('Postgres Driver', (group) => { configureDatabaseGroupHooks(db, group) - registerStoreTestSuite({ test, store: DatabaseStore, config: { dialect: 'pg', connection: db }, }) - - test('create table with specified tableName', async ({ assert, cleanup }) => { - const store = new DatabaseStore({ - connection: db, - dialect: 'pg', - tableName: 'verrou_my_locks', - }) - - cleanup(async () => { - await db.schema.dropTable('verrou_my_locks') - }) - - await store.save('foo', 'bar') - - const locks = await db.table('verrou_my_locks').select('*') - assert.lengthOf(locks, 1) - }) })