./docker/postgres-dev-init.sql:/docker-entrypoint-initdb.d/init.sql # will setup dev database adonis_app for us
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
5432:5432
volumes:
postgres_volume:
`docker compose up`
3. Add the database credentials above to .env
4. In `tests/bootstrap.ts`:
Package version
6.9.0
Describe the bug
Apologies if this issue would be better in vine or lucid repos, but it seems to touch on all through pacakges, so thought it best to report here.
Everytime I run a very basic test with
npm run test
I get the error:[ error ] Migration completed, but unable to release database lock
This then causes the test results to hang and not quit which is painful when running individual tests within VSCode.
I have looked on discord and found a number of people having a similar issue:
https://discord.com/channels/423256550564691970/1246405673772646432 https://discord.com/channels/423256550564691970/1113490995892457573 https://discord.com/channels/423256550564691970/423256550564691972/1087399322506768497
I have created some steps to recreate:
docker-compose.yml
with following content:services: st_postgres: container_name: test_postgres image: postgres:13 volumes:
volumes: postgres_volume:
export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = { setup: [() => testUtils.db().truncate()], teardown: [], }
import { test } from '@japa/runner'
test.group('A test just so something executes', (group) => { test('Test that something happens', async ({ assert }) => { assert.equal(true, true) }) })
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema { protected tableName = 'tests'
async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id')
}
async down() { this.schema.dropTable(this.tableName) } }
[ error ] Migration completed, but unable to release database lock