diff --git a/.bin/test.js b/.bin/test.js
deleted file mode 100644
index ec41c1bc..00000000
--- a/.bin/test.js
+++ /dev/null
@@ -1,11 +0,0 @@
-require('@adonisjs/require-ts/build/register')
-
-const { configure } = require('japa')
-configure({
- files: ['test/**/*.spec.ts', '!test/database/drop-tables.spec.ts'],
- after: [
- async () => {
- await require('fs-extra').remove(require('path').join(__dirname, 'test-helpers', 'tmp'))
- },
- ],
-})
diff --git a/bin/japaTypes.ts b/bin/japaTypes.ts
new file mode 100644
index 00000000..d42cac68
--- /dev/null
+++ b/bin/japaTypes.ts
@@ -0,0 +1,7 @@
+import { Assert } from '@japa/assert'
+
+declare module '@japa/runner' {
+ interface TestContext {
+ assert: Assert
+ }
+}
diff --git a/bin/test.ts b/bin/test.ts
new file mode 100644
index 00000000..c4c6521a
--- /dev/null
+++ b/bin/test.ts
@@ -0,0 +1,44 @@
+import { assert } from '@japa/assert'
+import { specReporter } from '@japa/spec-reporter'
+import { runFailedTests } from '@japa/run-failed-tests'
+import { processCliArgs, configure, run } from '@japa/runner'
+import { remove } from 'fs-extra'
+import { join } from 'path'
+
+/*
+|--------------------------------------------------------------------------
+| Configure tests
+|--------------------------------------------------------------------------
+|
+| The configure method accepts the configuration to configure the Japa
+| tests runner.
+|
+| The first method call "processCliArgs" process the command line arguments
+| and turns them into a config object. Using this method is not mandatory.
+|
+| Please consult japa.dev/runner-config for the config docs.
+*/
+configure({
+ ...processCliArgs(process.argv.slice(2)),
+ ...{
+ files: ['test/**/*.spec.ts', '!test/database/drop-table.spec.ts'],
+ plugins: [assert(), runFailedTests()],
+ reporters: [specReporter()],
+ importer: (filePath: string) => import(filePath),
+ teardown: [
+ async () => {
+ await remove(join(__dirname, 'test-helpers', 'tmp'))
+ },
+ ],
+ },
+})
+
+/*
+|--------------------------------------------------------------------------
+| Run tests
+|--------------------------------------------------------------------------
+|
+| The following "run" method is required to execute all the tests.
+|
+*/
+run()
diff --git a/package.json b/package.json
index d4ae12aa..c1e5f451 100644
--- a/package.json
+++ b/package.json
@@ -16,12 +16,12 @@
"scripts": {
"mrm": "mrm --preset=@adonisjs/mrm-preset",
"pretest": "npm run lint",
- "test:better_sqlite": "cross-env DB=better_sqlite FORCE_COLOR=true node ./.bin/test.js",
- "test:sqlite": "cross-env DB=sqlite FORCE_COLOR=true node ./.bin/test.js",
- "test:mysql": "cross-env DB=mysql FORCE_COLOR=true node ./.bin/test.js",
- "test:mysql_legacy": "cross-env DB=mysql_legacy FORCE_COLOR=true node ./.bin/test.js",
- "test:mssql": "cross-env DB=mssql FORCE_COLOR=true node ./.bin/test.js",
- "test:pg": "cross-env DB=pg FORCE_COLOR=true node ./.bin/test.js",
+ "test:better_sqlite": "cross-env DB=better_sqlite FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
+ "test:sqlite": "cross-env DB=sqlite FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
+ "test:mysql": "cross-env DB=mysql FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
+ "test:mysql_legacy": "cross-env DB=mysql_legacy FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
+ "test:mssql": "cross-env DB=mssql FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
+ "test:pg": "cross-env DB=pg FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts",
"test:docker": "npm run test:mysql && npm run test:mysql_legacy && npm run test:pg && npm run test:mssql",
"test": "docker-compose -f docker-compose.yml -f docker-compose-test.yml build && docker-compose -f docker-compose.yml -f docker-compose-test.yml run --rm test && npm run test:sqlite && npm run test:better_sqlite",
"lint": "eslint . --ext=.ts",
@@ -69,6 +69,10 @@
"@adonisjs/repl": "^3.1.8",
"@adonisjs/require-ts": "^2.0.10",
"@adonisjs/sink": "^5.2.2",
+ "@japa/assert": "^1.2.3",
+ "@japa/run-failed-tests": "^1.0.3",
+ "@japa/runner": "^1.2.0",
+ "@japa/spec-reporter": "^1.1.7",
"@poppinss/dev-utils": "^2.0.2",
"@types/luxon": "^2.0.9",
"@types/node": "^17.0.21",
@@ -90,7 +94,6 @@
"fs-extra": "^10.0.1",
"github-label-sync": "^2.0.1",
"husky": "^7.0.4",
- "japa": "^4.0.0",
"mrm": "^3.0.10",
"mysql": "^2.18.1",
"np": "^7.6.0",
diff --git a/src/Dialects/Mysql.ts b/src/Dialects/Mysql.ts
index 9cd3d811..f4e7a421 100644
--- a/src/Dialects/Mysql.ts
+++ b/src/Dialects/Mysql.ts
@@ -96,6 +96,8 @@ export class MysqlDialect implements DialectContract {
public async dropAllTables() {
let tables = await this.getAllTables()
+ if (!tables.length) return
+
/**
* Add backquote around table names to avoid syntax errors
* in case of a table name with a reserved keyword
diff --git a/test/bindings/validator.spec.ts b/test/bindings/validator.spec.ts
index 2b1419b9..e5365500 100644
--- a/test/bindings/validator.spec.ts
+++ b/test/bindings/validator.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { rules } from '@adonisjs/validator/build/src/Rules'
import { schema } from '@adonisjs/validator/build/src/Schema'
import { extendValidator } from '../../src/Bindings/Validator'
@@ -23,25 +23,25 @@ let app: ApplicationContract
let db: ReturnType
test.group('Validator | exists', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
await setup()
extendValidator(validator, db, app.logger)
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
- await fs.cleanup()
await db.manager.closeAll()
+ await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
db.connection().getReadClient().removeAllListeners()
})
- test("must fail when row doesn't exists in the table", async (assert) => {
+ test("must fail when row doesn't exists in the table", async ({ assert }) => {
assert.plan(1)
try {
@@ -63,7 +63,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('work fine when row exists', async (assert) => {
+ test('work fine when row exists', async ({ assert }) => {
assert.plan(2)
const [row] = await db
@@ -101,7 +101,7 @@ test.group('Validator | exists', (group) => {
})
})
- test('add where contraints', async (assert) => {
+ test('add where contraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -149,7 +149,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add where contraints with refs', async (assert) => {
+ test('add where contraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -202,7 +202,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add wherein contraints', async (assert) => {
+ test('add wherein contraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -250,7 +250,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add wherein contraints with refs', async (assert) => {
+ test('add wherein contraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -303,7 +303,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add where not constraints', async (assert) => {
+ test('add where not constraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -351,7 +351,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add where not constraints with refs', async (assert) => {
+ test('add where not constraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -404,7 +404,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add where not in constraints', async (assert) => {
+ test('add where not in constraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -452,7 +452,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('add where not in constraints with refs', async (assert) => {
+ test('add where not in constraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -505,7 +505,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('perform case-insensitive query', async (assert) => {
+ test('perform case-insensitive query', async ({ assert }) => {
assert.plan(2)
await db.table('users').returning('id').insert({ email: 'virk@adonisjs.com', username: 'virk' })
@@ -541,7 +541,7 @@ test.group('Validator | exists', (group) => {
})
})
- test('do not report SQL errors to the validator', async (assert) => {
+ test('do not report SQL errors to the validator', async ({ assert }) => {
assert.plan(1)
try {
@@ -564,7 +564,7 @@ test.group('Validator | exists', (group) => {
}
})
- test('make correct sql query schema field is of date type', async (assert) => {
+ test('make correct sql query schema field is of date type', async ({ assert }) => {
assert.plan(3)
let sql: any
@@ -618,7 +618,7 @@ test.group('Validator | exists', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('define custom format datetime values', async (assert) => {
+ test('define custom format datetime values', async ({ assert }) => {
assert.plan(3)
let sql: any
@@ -671,25 +671,25 @@ test.group('Validator | exists', (group) => {
})
test.group('Validator | unique', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
await setup()
extendValidator(validator, db, app.logger)
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
- await fs.cleanup()
await db.manager.closeAll()
+ await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
db.connection().getReadClient().removeAllListeners()
})
- test('must fail when row already exists in the table', async (assert) => {
+ test('must fail when row already exists in the table', async ({ assert }) => {
assert.plan(1)
const [row] = await db
@@ -730,7 +730,7 @@ test.group('Validator | unique', (group) => {
})
})
- test('add where contraints', async (assert) => {
+ test('add where contraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -778,7 +778,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add where contraints with refs', async (assert) => {
+ test('add where contraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -831,7 +831,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add where in contraints', async (assert) => {
+ test('add where in contraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -879,7 +879,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add where in contraints with refs', async (assert) => {
+ test('add where in contraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -932,7 +932,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add whereNot contraints', async (assert) => {
+ test('add whereNot contraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -980,7 +980,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add whereNot contraints with refs', async (assert) => {
+ test('add whereNot contraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -1033,7 +1033,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add whereNot in contraints', async (assert) => {
+ test('add whereNot in contraints', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -1081,7 +1081,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('add whereNot in contraints with refs', async (assert) => {
+ test('add whereNot in contraints with refs', async ({ assert }) => {
assert.plan(3)
const [row] = await db
@@ -1134,7 +1134,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('perform case-insensitive check', async (assert) => {
+ test('perform case-insensitive check', async ({ assert }) => {
assert.plan(3)
await db.table('users').returning('id').insert({ email: 'virk@adonisjs.com', username: 'virk' })
@@ -1175,7 +1175,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('do not report SQL errors to the validator', async (assert) => {
+ test('do not report SQL errors to the validator', async ({ assert }) => {
assert.plan(1)
try {
@@ -1198,7 +1198,7 @@ test.group('Validator | unique', (group) => {
}
})
- test('make correct sql query schema field is of date type', async (assert) => {
+ test('make correct sql query schema field is of date type', async ({ assert }) => {
assert.plan(3)
await db
@@ -1256,7 +1256,7 @@ test.group('Validator | unique', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('define custom format datetime values', async (assert) => {
+ test('define custom format datetime values', async ({ assert }) => {
assert.plan(3)
await db
diff --git a/test/commands/db-seed.spec.ts b/test/commands/db-seed.spec.ts
index fd4f3779..a1a14d28 100644
--- a/test/commands/db-seed.spec.ts
+++ b/test/commands/db-seed.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import 'reflect-metadata'
import { Kernel } from '@adonisjs/core/build/standalone'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -21,20 +21,20 @@ let app: ApplicationContract
let db: ReturnType
test.group('DbSeed', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
app.container.bind('Adonis/Lucid/Database', () => db)
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await cleanup()
await cleanup(['adonis_schema', 'adonis_schema_versions', 'schema_users', 'schema_accounts'])
await fs.cleanup()
})
- test('run seeds', async (assert) => {
+ test('run seeds', async ({ assert }) => {
await fs.add(
'database/seeders/user.ts',
`export default class UserSeeder {
@@ -51,7 +51,7 @@ test.group('DbSeed', (group) => {
delete process.env.EXEC_USER_SEEDER
})
- test('run custom files', async (assert) => {
+ test('run custom files', async ({ assert }) => {
await fs.add(
'database/seeders/user.ts',
`export default class UserSeeder {
diff --git a/test/commands/make-migration.spec.ts b/test/commands/make-migration.spec.ts
index 1d104b4b..21bcac77 100644
--- a/test/commands/make-migration.spec.ts
+++ b/test/commands/make-migration.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import 'reflect-metadata'
import { join } from 'path'
import { Kernel } from '@adonisjs/core/build/standalone'
@@ -34,27 +34,27 @@ let app: ApplicationContract
const templatesFs = new Filesystem(join(__dirname, '..', '..', 'templates'))
test.group('MakeMigration', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
await setup()
})
- group.beforeEach(() => {
+ group.each.setup(() => {
app.container.bind('Adonis/Lucid/Database', () => db)
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await cleanup(['adonis_schema', 'adonis_schema_versions', 'schema_users', 'schema_accounts'])
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create migration in the default migrations directory', async (assert) => {
+ test('create migration in the default migrations directory', async ({ assert }) => {
const makeMigration = new MakeMigration(app, new Kernel(app))
makeMigration.name = 'users'
await makeMigration.run()
@@ -75,7 +75,7 @@ test.group('MakeMigration', (group) => {
)
})
- test('create migration for alter table', async (assert) => {
+ test('create migration for alter table', async ({ assert }) => {
const makeMigration = new MakeMigration(app, new Kernel(app))
makeMigration.name = 'users'
makeMigration.table = 'my_users'
@@ -98,7 +98,7 @@ test.group('MakeMigration', (group) => {
)
})
- test('create migration for make table with custom table name', async (assert) => {
+ test('create migration for make table with custom table name', async ({ assert }) => {
const makeMigration = new MakeMigration(app, new Kernel(app))
makeMigration.name = 'users'
makeMigration.create = 'my_users'
@@ -121,7 +121,7 @@ test.group('MakeMigration', (group) => {
)
})
- test('create nested migration file', async (assert) => {
+ test('create nested migration file', async ({ assert }) => {
const makeMigration = new MakeMigration(app, new Kernel(app))
makeMigration.name = 'profile/users'
@@ -143,7 +143,7 @@ test.group('MakeMigration', (group) => {
)
})
- test('raise error when defined connection is invalid', async (assert) => {
+ test('raise error when defined connection is invalid', async ({ assert }) => {
const makeMigration = new MakeMigration(app, new Kernel(app))
makeMigration.name = 'profile/users'
makeMigration.connection = 'foo'
@@ -158,7 +158,7 @@ test.group('MakeMigration', (group) => {
])
})
- test('prompt for migration paths when multiple paths are defined', async (assert) => {
+ test('prompt for migration paths when multiple paths are defined', async ({ assert }) => {
const config = {
connection: 'primary',
connections: {
@@ -206,7 +206,7 @@ test.group('MakeMigration', (group) => {
await customDb.manager.closeAll()
})
- test('use custom directory when defined', async (assert) => {
+ test('use custom directory when defined', async ({ assert }) => {
const config = {
connection: 'primary',
connections: {
diff --git a/test/commands/make-model.spec.ts b/test/commands/make-model.spec.ts
index 8f626131..f90a90fb 100644
--- a/test/commands/make-model.spec.ts
+++ b/test/commands/make-model.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import 'reflect-metadata'
import { join } from 'path'
import { Kernel } from '@adonisjs/core/build/standalone'
@@ -21,12 +21,12 @@ import MakeModel from '../../commands/MakeModel'
const templatesFs = new Filesystem(join(__dirname, '..', '..', 'templates'))
test.group('MakeModel', (group) => {
- group.afterEach(async () => {
+ group.each.teardown(async () => {
delete process.env.ADONIS_ACE_CWD
await fs.cleanup()
})
- test('make a model inside the default directory', async (assert) => {
+ test('make a model inside the default directory', async ({ assert }) => {
const app = await setupApplication()
const makeModel = new MakeModel(app, new Kernel(app))
@@ -42,7 +42,7 @@ test.group('MakeModel', (group) => {
)
})
- test('make a model inside a custom directory', async (assert) => {
+ test('make a model inside a custom directory', async ({ assert }) => {
const app = await setupApplication()
app.rcFile.namespaces.models = 'App'
diff --git a/test/commands/migrate.spec.ts b/test/commands/migrate.spec.ts
index da58338c..d0b89792 100644
--- a/test/commands/migrate.spec.ts
+++ b/test/commands/migrate.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import 'reflect-metadata'
import { join } from 'path'
import { Kernel } from '@adonisjs/core/build/standalone'
@@ -26,7 +26,7 @@ let db: ReturnType
let app: ApplicationContract
test.group('Migrate', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
app.container.bind('Adonis/Lucid/Database', () => db)
@@ -34,13 +34,14 @@ test.group('Migrate', (group) => {
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
+ await db.manager.closeAll()
await cleanup()
await cleanup(['adonis_schema', 'adonis_schema_versions', 'schema_users', 'schema_accounts'])
await fs.cleanup()
})
- test('run migrations from default directory', async (assert) => {
+ test('run migrations from default directory', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -73,7 +74,7 @@ test.group('Migrate', (group) => {
assert.equal(migrated[0].batch, 1)
})
- test('skip migrations when already up to date', async (assert) => {
+ test('skip migrations when already up to date', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'database/migrations'))
const migrate = new Migrate(app, new Kernel(app))
@@ -88,7 +89,7 @@ test.group('Migrate', (group) => {
assert.lengthOf(migrated, 0)
})
- test('print sql queries in dryRun', async (assert) => {
+ test('print sql queries in dryRun', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -117,7 +118,7 @@ test.group('Migrate', (group) => {
assert.lengthOf(migrated, 0)
})
- test('prompt during migrations in production without force flag', async (assert) => {
+ test('prompt during migrations in production without force flag', async ({ assert }) => {
assert.plan(1)
app.nodeEnvironment = 'production'
@@ -176,7 +177,7 @@ test.group('Migrate', (group) => {
delete process.env.NODE_ENV
})
- test('prompt during rollback in production without force flag', async (assert) => {
+ test('prompt during rollback in production without force flag', async ({ assert }) => {
assert.plan(1)
app.nodeEnvironment = 'production'
@@ -228,7 +229,7 @@ test.group('Migrate', (group) => {
delete process.env.NODE_ENV
})
- test('migration:reset should rollback to batch 0', async (assert) => {
+ test('migration:reset should rollback to batch 0', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -284,7 +285,9 @@ test.group('Migrate', (group) => {
assert.isFalse(hasAccountsTable)
})
- test('migration:refresh should rollback to batch 0 then run all migrations', async (assert) => {
+ test('migration:refresh should rollback to batch 0 then run all migrations', async ({
+ assert,
+ }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -340,14 +343,16 @@ test.group('Migrate', (group) => {
assert.isTrue(hasAccountsTable)
})
- test('migration:refresh --seed should rollback to batch 0, run all migrations then run seeders', async (assert) => {
+ test('migration:refresh --seed should rollback to batch 0, run all migrations then run seeders', async ({
+ assert,
+ }) => {
await fs.add(
'database/seeders/user.ts',
`export default class UserSeeder {
- public async run () {
- process.env.EXEC_USER_SEEDER = 'true'
- }
- }`
+ public async run () {
+ process.env.EXEC_USER_SEEDER = 'true'
+ }
+ }`
)
await fs.add(
diff --git a/test/commands/wipe-fresh.spec.ts b/test/commands/wipe-fresh.spec.ts
index 6c5a9764..88b2be14 100644
--- a/test/commands/wipe-fresh.spec.ts
+++ b/test/commands/wipe-fresh.spec.ts
@@ -1,6 +1,6 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import 'reflect-metadata'
import { Kernel } from '@adonisjs/core/build/standalone'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -14,7 +14,7 @@ let app: ApplicationContract
let db: ReturnType
test.group('db:wipe and migrate:fresh', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
app.container.bind('Adonis/Lucid/Database', () => db)
@@ -22,13 +22,14 @@ test.group('db:wipe and migrate:fresh', (group) => {
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
+ await db.manager.closeAll()
await cleanup()
await cleanup(['adonis_schema', 'adonis_schema_versions', 'schema_users'])
await fs.cleanup()
})
- test('db:wipe should drop all tables', async (assert) => {
+ test('db:wipe should drop all tables', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -46,18 +47,20 @@ test.group('db:wipe and migrate:fresh', (group) => {
const kernel = new Kernel(app)
const migrate = new Migrate(app, kernel)
await migrate.run()
+ await db.manager.closeAll()
db = getDb(app)
const wipe = new DbWipe(app, kernel)
await wipe.run()
+ await db.manager.closeAll()
db = getDb(app)
const tables = await db.connection().getAllTables(['public'])
assert.lengthOf(tables, 0)
})
- test('migration:fresh should drop all tables and run migrations', async (assert) => {
+ test('migration:fresh should drop all tables and run migrations', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -92,14 +95,14 @@ test.group('db:wipe and migrate:fresh', (group) => {
assert.equal(migrated[0].batch, 1)
})
- test('migration:fresh --seed should run seeders', async (assert) => {
+ test('migration:fresh --seed should run seeders', async ({ assert }) => {
await fs.add(
'database/seeders/user.ts',
`export default class UserSeeder {
- public async run () {
- process.env.EXEC_USER_SEEDER = 'true'
- }
- }`
+ public async run () {
+ process.env.EXEC_USER_SEEDER = 'true'
+ }
+ }`
)
await fs.add(
diff --git a/test/connection/connection-manager.spec.ts b/test/connection/connection-manager.spec.ts
index 5c90b69e..adedbfaa 100644
--- a/test/connection/connection-manager.spec.ts
+++ b/test/connection/connection-manager.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { Connection } from '../../src/Connection'
@@ -20,20 +20,20 @@ import { join } from 'path'
let app: ApplicationContract
test.group('ConnectionManager', (group) => {
- group.before(async () => {
+ group.setup(async () => {
await setup()
})
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('do not connect until connect is called', async (assert) => {
+ test('do not connect until connect is called', async ({ assert }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', getConfig())
@@ -42,7 +42,7 @@ test.group('ConnectionManager', (group) => {
await manager.closeAll()
})
- test('connect and set its state to open', async (assert) => {
+ test('connect and set its state to open', async ({ assert }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', getConfig())
manager.connect('primary')
@@ -52,7 +52,7 @@ test.group('ConnectionManager', (group) => {
await manager.closeAll()
})
- test('on disconnect set state to closed', async (assert) => {
+ test('on disconnect set state to closed', async ({ assert }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', getConfig())
manager.connect('primary')
@@ -63,7 +63,7 @@ test.group('ConnectionManager', (group) => {
await manager.closeAll()
})
- test('add duplicate connection must be a noop', async (assert) => {
+ test('add duplicate connection must be a noop', async ({ assert }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', getConfig())
manager.connect('primary')
@@ -73,7 +73,7 @@ test.group('ConnectionManager', (group) => {
await manager.closeAll()
})
- test('patch config when connection is not in open state', async (assert) => {
+ test('patch config when connection is not in open state', async ({ assert }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', getConfig())
manager.connect('primary')
@@ -81,7 +81,7 @@ test.group('ConnectionManager', (group) => {
await manager.close('primary')
const fn = () => manager.add('primary', getConfig())
- assert.doesNotThrow(fn)
+ assert.doesNotThrows(fn)
await manager.closeAll()
})
@@ -103,9 +103,9 @@ test.group('ConnectionManager', (group) => {
manager.connect('primary')
manager.connect('primary')
await manager.closeAll()
- })
+ }).waitForDone()
- test('releasing a connection must close it first', async (assert) => {
+ test('releasing a connection must close it first', async ({ assert }) => {
assert.plan(2)
const emitter = app.container.use('Adonis/Core/Event')
@@ -122,7 +122,7 @@ test.group('ConnectionManager', (group) => {
assert.isFalse(manager.has('primary'))
})
- test('proxy error event', async (assert, done) => {
+ test('proxy error event', async ({ assert }, done) => {
assert.plan(3)
const emitter = app.container.use('Adonis/Core/Event')
@@ -142,10 +142,12 @@ test.group('ConnectionManager', (group) => {
})
const fn = () => manager.connect('primary')
- assert.throw(fn, /knex: Required configuration option/)
- })
+ assert.throws(fn, /knex: Required configuration option/)
+ }).waitForDone()
- test('patching the connection config must close old and create a new connection', async (assert, done) => {
+ test('patching the connection config must close old and create a new connection', async ({
+ assert,
+ }, done) => {
assert.plan(6)
let connections: any[] = []
@@ -188,9 +190,11 @@ test.group('ConnectionManager', (group) => {
*/
manager.patch('primary', getConfig())
manager.connect('primary')
- })
+ }).waitForDone()
- test('get health check report for connections that has enabled health checks', async (assert) => {
+ test('get health check report for connections that has enabled health checks', async ({
+ assert,
+ }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', Object.assign({}, getConfig(), { healthCheck: true }))
manager.add('secondary', Object.assign({}, getConfig(), { healthCheck: true }))
@@ -204,9 +208,11 @@ test.group('ConnectionManager', (group) => {
report.meta.map(({ connection }) => connection),
['primary', 'secondary']
)
+
+ await manager.closeAll()
})
- test('get health check report when one of the connection is unhealthy', async (assert) => {
+ test('get health check report when one of the connection is unhealthy', async ({ assert }) => {
const manager = new ConnectionManager(app.logger, app.container.use('Adonis/Core/Event'))
manager.add('primary', Object.assign({}, getConfig(), { healthCheck: true }))
manager.add(
@@ -232,5 +238,6 @@ test.group('ConnectionManager', (group) => {
report.meta.map(({ connection }) => connection),
['primary', 'secondary']
)
+ await manager.closeAll()
}).timeout(0)
})
diff --git a/test/connection/connection.spec.ts b/test/connection/connection.spec.ts
index f71f8a3f..f4b98f54 100644
--- a/test/connection/connection.spec.ts
+++ b/test/connection/connection.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { MysqlConfig } from '@ioc:Adonis/Lucid/Database'
import { Connection } from '../../src/Connection'
@@ -20,17 +20,17 @@ let app: ApplicationContract
if (process.env.DB !== 'sqlite') {
test.group('Connection | config', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('get write config by merging values from connection', (assert) => {
+ test('get write config by merging values from connection', ({ assert }) => {
const config = getConfig()
config.replicas! = {
write: {
@@ -54,7 +54,7 @@ if (process.env.DB !== 'sqlite') {
assert.equal(writeConfig.connection!['host'], '10.0.0.1')
})
- test('get read config by merging values from connection', (assert) => {
+ test('get read config by merging values from connection', ({ assert }) => {
const config = getConfig()
config.replicas! = {
write: {
@@ -80,26 +80,27 @@ if (process.env.DB !== 'sqlite') {
}
test.group('Connection | setup', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('do not instantiate knex unless connect is called', (assert) => {
+ test('do not instantiate knex unless connect is called', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
+
assert.isUndefined(connection.client)
})
- test('instantiate knex when connect is invoked', async (assert, done) => {
+ test('instantiate knex when connect is invoked', async ({ assert }, done) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.on('connect', async () => {
assert.isDefined(connection.client!)
@@ -109,9 +110,9 @@ test.group('Connection | setup', (group) => {
})
connection.connect()
- })
+ }).waitForDone()
- test('on disconnect destroy knex', async (assert) => {
+ test('on disconnect destroy knex', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
await connection.disconnect()
@@ -120,7 +121,7 @@ test.group('Connection | setup', (group) => {
assert.isUndefined(connection['_readClient'])
})
- test('on disconnect emit disconnect event', async (assert, done) => {
+ test('on disconnect emit disconnect event', async ({ assert }, done) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -130,9 +131,9 @@ test.group('Connection | setup', (group) => {
})
await connection.disconnect()
- })
+ }).waitForDone()
- test('raise error when unable to make connection', (assert, done) => {
+ test('raise error when unable to make connection', ({ assert }, done) => {
assert.plan(2)
const connection = new Connection(
@@ -151,13 +152,13 @@ test.group('Connection | setup', (group) => {
})
const fn = () => connection.connect()
- assert.throw(fn, /knex: Required configuration option/)
- })
+ assert.throws(fn, /knex: Required configuration option/)
+ }).waitForDone()
})
if (process.env.DB === 'mysql') {
test.group('Connection | setup mysql', () => {
- test('pass user config to mysql driver', async (assert) => {
+ test('pass user config to mysql driver', async ({ assert }) => {
const config = getConfig() as MysqlConfig
config.connection!.charset = 'utf-8'
config.connection!.typeCast = false
@@ -174,17 +175,17 @@ if (process.env.DB === 'mysql') {
}
test.group('Health Checks', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('get healthcheck report for healthy connection', async (assert) => {
+ test('get healthcheck report for healthy connection', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -199,7 +200,7 @@ test.group('Health Checks', (group) => {
})
if (!['sqlite', 'better_sqlite'].includes(process.env.DB!)) {
- test('get healthcheck report for un-healthy connection', async (assert) => {
+ test('get healthcheck report for un-healthy connection', async ({ assert }) => {
const connection = new Connection(
'primary',
Object.assign({}, getConfig(), {
@@ -218,7 +219,7 @@ test.group('Health Checks', (group) => {
await connection.disconnect()
}).timeout(0)
- test('get healthcheck report for un-healthy read host', async (assert) => {
+ test('get healthcheck report for un-healthy read host', async ({ assert }) => {
const connection = new Connection(
'primary',
Object.assign({}, getConfig(), {
diff --git a/test/database-provider.spec.ts b/test/database-provider.spec.ts
index 26ae57c7..e234993a 100644
--- a/test/database-provider.spec.ts
+++ b/test/database-provider.spec.ts
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
-import test from 'japa'
+import { test } from '@japa/runner'
import { Database } from '../src/Database'
import { scope } from '../src/Helpers/scope'
@@ -21,11 +21,11 @@ import { SnakeCaseNamingStrategy } from '../src/Orm/NamingStrategies/SnakeCase'
import { setupApplication, fs } from '../test-helpers'
test.group('Database Provider', (group) => {
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await fs.cleanup()
})
- test('register database provider', async (assert) => {
+ test('register database provider', async ({ assert }) => {
const app = await setupApplication(
{
connection: 'sqlite',
@@ -49,7 +49,7 @@ test.group('Database Provider', (group) => {
assert.deepEqual(app.container.use('Adonis/Lucid/Seeder'), BaseSeeder)
})
- test('register health checker', async (assert) => {
+ test('register health checker', async ({ assert }) => {
const app = await setupApplication(
{
connection: 'sqlite',
@@ -66,7 +66,7 @@ test.group('Database Provider', (group) => {
assert.equal(HealthCheck['healthCheckers']['lucid'], 'Adonis/Lucid/Database')
})
- test('register validator rules', async (assert) => {
+ test('register validator rules', async ({ assert }) => {
const app = await setupApplication(
{
connection: 'sqlite',
@@ -82,7 +82,7 @@ test.group('Database Provider', (group) => {
assert.property(Validator['rules'], 'exists')
})
- test('register repl bindings in repl environment', async (assert) => {
+ test('register repl bindings in repl environment', async ({ assert }) => {
const app = await setupApplication(
{
connection: 'sqlite',
diff --git a/test/database/database.spec.ts b/test/database/database.spec.ts
index ae3eb74d..e4c5db52 100644
--- a/test/database/database.spec.ts
+++ b/test/database/database.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { Database } from '../../src/Database'
@@ -18,17 +18,17 @@ import { fs, getConfig, setup, cleanup, getDb, setupApplication } from '../../te
let app: ApplicationContract
test.group('Database', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('register all connections with the manager', (assert) => {
+ test('register all connections with the manager', ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -46,7 +46,7 @@ test.group('Database', (group) => {
assert.isUndefined(db.manager.connections.get('primary')!.connection)
})
- test('make connection when db.connection is called', async (assert, done) => {
+ test('make connection when db.connection is called', async ({ assert }, done) => {
assert.plan(1)
const config = {
@@ -63,9 +63,9 @@ test.group('Database', (group) => {
db.connection()
await db.manager.closeAll()
- })
+ }).waitForDone()
- test('make connection to a named connection', async (assert, done) => {
+ test('make connection to a named connection', async ({ assert }, done) => {
assert.plan(1)
const config = {
@@ -82,9 +82,9 @@ test.group('Database', (group) => {
db.connection('primary')
await db.manager.closeAll()
- })
+ }).waitForDone()
- test('make connection to a named connection in write mode', async (assert) => {
+ test('make connection to a named connection in write mode', async ({ assert }) => {
assert.plan(1)
const config = {
@@ -104,7 +104,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('make connection to a named connection in read mode', async (assert) => {
+ test('make connection to a named connection in read mode', async ({ assert }) => {
assert.plan(1)
const config = {
@@ -124,7 +124,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('get transaction instance', async (assert) => {
+ test('get transaction instance', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -145,7 +145,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('get raw query builder instance', async (assert) => {
+ test('get raw query builder instance', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -162,7 +162,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('get raw query builder instance in read mode', async (assert) => {
+ test('get raw query builder instance in read mode', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -179,7 +179,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('get raw query builder instance in write mode', async (assert) => {
+ test('get raw query builder instance in write mode', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -196,7 +196,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('pass profiler to query client', async (assert) => {
+ test('pass profiler to query client', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -210,7 +210,7 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('pass custom profiler to query client', async (assert) => {
+ test('pass custom profiler to query client', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -226,7 +226,9 @@ test.group('Database', (group) => {
await db.manager.closeAll()
})
- test('set hasHealthChecks enabled flag to true, when one ore more connections are using health checks', async (assert) => {
+ test('set hasHealthChecks enabled flag to true, when one ore more connections are using health checks', async ({
+ assert,
+ }) => {
const config = {
connection: 'primary',
connections: { primary: Object.assign({}, getConfig(), { healthCheck: true }) },
@@ -244,17 +246,17 @@ test.group('Database', (group) => {
})
test.group('Database | extend', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('extend database query builder by adding macros', async (assert) => {
+ test('extend database query builder by adding macros', async ({ assert }) => {
const db = getDb(app)
db.DatabaseQueryBuilder.macro('whereActive', function whereActive() {
@@ -276,7 +278,7 @@ test.group('Database | extend', (group) => {
await db.manager.closeAll()
})
- test('extend insert query builder by adding macros', async (assert) => {
+ test('extend insert query builder by adding macros', async ({ assert }) => {
const db = getDb(app)
db.InsertQueryBuilder.macro('returnId', function whereActive() {
@@ -307,17 +309,17 @@ test.group('Database | extend', (group) => {
})
test.group('Database | global transaction', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('perform queries inside a global transaction', async (assert) => {
+ test('perform queries inside a global transaction', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -341,7 +343,7 @@ test.group('Database | global transaction', (group) => {
await db.manager.closeAll()
})
- test('create transactions inside a global transaction', async (assert) => {
+ test('create transactions inside a global transaction', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
@@ -368,7 +370,7 @@ test.group('Database | global transaction', (group) => {
await db.manager.closeAll()
})
- test('multiple calls to beginGlobalTransaction must be a noop', async (assert) => {
+ test('multiple calls to beginGlobalTransaction must be a noop', async ({ assert }) => {
const config = {
connection: 'primary',
connections: { primary: getConfig() },
diff --git a/test/database/drop-tables.spec.ts b/test/database/drop-tables.spec.ts
index 9e794f24..2129f06f 100644
--- a/test/database/drop-tables.spec.ts
+++ b/test/database/drop-tables.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { join } from 'path'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -20,18 +20,18 @@ import { fs, getConfig, setup, cleanup, setupApplication } from '../../test-help
let app: ApplicationContract
test.group('Query client | drop tables', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup(['temp_posts', 'temp_users'])
await cleanup()
await fs.cleanup()
})
- test('drop all tables', async (assert) => {
+ test('drop all tables', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'temp'))
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -61,9 +61,11 @@ test.group('Query client | drop tables', (group) => {
assert.isFalse(await connection.client!.schema.hasTable('comments'))
assert.isFalse(await connection.client!.schema.hasTable('profiles'))
assert.isFalse(await connection.client!.schema.hasTable('identities'))
+
+ await connection.disconnect()
})
- test('dropAllTables should not throw when there are no tables', async (assert) => {
+ test('dropAllTables should not throw when there are no tables', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'temp'))
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -76,5 +78,7 @@ test.group('Query client | drop tables', (group) => {
} catch (err) {
assert.fail(err)
}
+
+ await connection.disconnect()
})
})
diff --git a/test/database/insert-query-builder.spec.ts b/test/database/insert-query-builder.spec.ts
index 9cea5388..75ac0e1f 100644
--- a/test/database/insert-query-builder.spec.ts
+++ b/test/database/insert-query-builder.spec.ts
@@ -10,7 +10,7 @@
///
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
-import test from 'japa'
+import { test } from '@japa/runner'
import { Connection } from '../../src/Connection'
import {
@@ -27,17 +27,17 @@ import {
let app: ApplicationContract
test.group('Query Builder | insert', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('perform insert', async (assert) => {
+ test('perform insert', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -55,7 +55,7 @@ test.group('Query Builder | insert', (group) => {
await connection.disconnect()
})
- test('perform multi insert', async (assert) => {
+ test('perform multi insert', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -76,7 +76,7 @@ test.group('Query Builder | insert', (group) => {
await connection.disconnect()
})
- test('define returning columns', async (assert) => {
+ test('define returning columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -98,7 +98,7 @@ test.group('Query Builder | insert', (group) => {
await connection.disconnect()
})
- test('derive key value from raw query', async (assert) => {
+ test('derive key value from raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
diff --git a/test/database/query-builder.spec.ts b/test/database/query-builder.spec.ts
index 83a87fed..2d3dc86c 100644
--- a/test/database/query-builder.spec.ts
+++ b/test/database/query-builder.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { Connection } from '../../src/Connection'
import { QueryRunner } from '../../src/QueryRunner'
import { DatabaseQueryBuilder } from '../../src/Database/QueryBuilder/Database'
@@ -33,22 +33,22 @@ let app: ApplicationContract
if (process.env.DB !== 'sqlite') {
test.group('Query Builder | client', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use read client when making select query', async (assert) => {
+ test('use read client when making select query', async ({ assert }) => {
assert.plan(1)
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -65,7 +65,7 @@ if (process.env.DB !== 'sqlite') {
await connection.disconnect()
})
- test('use write client for update', async (assert) => {
+ test('use write client for update', async ({ assert }) => {
assert.plan(1)
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -84,7 +84,7 @@ if (process.env.DB !== 'sqlite') {
await connection.disconnect()
})
- test('use write client for delete', async (assert) => {
+ test('use write client for delete', async ({ assert }) => {
assert.plan(1)
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -101,7 +101,7 @@ if (process.env.DB !== 'sqlite') {
await connection.disconnect()
})
- test('use write client for inserts', async (assert) => {
+ test('use write client for inserts', async ({ assert }) => {
assert.plan(1)
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -193,27 +193,29 @@ if (process.env.DB !== 'sqlite') {
trx.insertQuery().table('users').insert({ username: 'virk' }).knexQuery
)
await trx.commit()
+
+ await connection.disconnect()
})
})
}
test.group('Query Builder | from', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define query table', async (assert) => {
+ test('define query table', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -226,7 +228,7 @@ test.group('Query Builder | from', (group) => {
await connection.disconnect()
})
- test('define table alias', (assert) => {
+ test('define table alias', ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -240,22 +242,22 @@ test.group('Query Builder | from', (group) => {
})
test.group('Query Builder | select', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define columns as array', async (assert) => {
+ test('define columns as array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -271,7 +273,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('define columns with aliases', async (assert) => {
+ test('define columns with aliases', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -287,7 +289,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('define columns as multiple arguments', async (assert) => {
+ test('define columns as multiple arguments', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -303,7 +305,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('define columns as multiple arguments with aliases', async (assert) => {
+ test('define columns as multiple arguments with aliases', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -319,7 +321,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('define columns as subqueries', async (assert) => {
+ test('define columns as subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -341,7 +343,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('define columns as subqueries inside an array', async (assert) => {
+ test('define columns as subqueries inside an array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -363,7 +365,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('chain select calls', async (assert) => {
+ test('chain select calls', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -386,7 +388,7 @@ test.group('Query Builder | select', (group) => {
await connection.disconnect()
})
- test('define columns as raw queries', async (assert) => {
+ test('define columns as raw queries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -415,22 +417,22 @@ test.group('Query Builder | select', (group) => {
})
test.group('Query Builder | where', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where clause', async (assert) => {
+ test('add where clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -465,7 +467,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap where clause to its own group', async (assert) => {
+ test('wrap where clause to its own group', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -511,7 +513,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add where clause as an object', async (assert) => {
+ test('add where clause as an object', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -544,7 +546,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add where wrapped clause', async (assert) => {
+ test('add where wrapped clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -580,7 +582,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap already wrapped where clause', async (assert) => {
+ test('wrap already wrapped where clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -622,7 +624,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add where clause with operator', async (assert) => {
+ test('add where clause with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -655,7 +657,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap where clause with operator', async (assert) => {
+ test('wrap where clause with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -697,7 +699,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add where clause as a raw query', async (assert) => {
+ test('add where clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -721,7 +723,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap raw query', async (assert) => {
+ test('wrap raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -750,7 +752,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add where clause as a raw builder query', async (assert) => {
+ test('add where clause as a raw builder query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -770,7 +772,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap raw query builder query', async (assert) => {
+ test('wrap raw query builder query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -790,7 +792,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add orWhere clause', async (assert) => {
+ test('add orWhere clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -827,7 +829,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap orWhere clause', async (assert) => {
+ test('wrap orWhere clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -870,7 +872,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add orWhere wrapped clause', async (assert) => {
+ test('add orWhere wrapped clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -921,7 +923,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap orWhere wrapped clause', async (assert) => {
+ test('wrap orWhere wrapped clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -972,7 +974,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('add where clause using ref', async (assert) => {
+ test('add where clause using ref', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1007,7 +1009,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('wrap where clause using ref', async (assert) => {
+ test('wrap where clause using ref', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1051,7 +1053,7 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})
- test('allow raw query for the column name', async (assert) => {
+ test('allow raw query for the column name', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1075,22 +1077,22 @@ test.group('Query Builder | where', (group) => {
})
test.group('Query Builder | whereNot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where not clause', async (assert) => {
+ test('add where not clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1124,7 +1126,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('wrap where not clause', async (assert) => {
+ test('wrap where not clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1167,7 +1169,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add where not clause as an object', async (assert) => {
+ test('add where not clause as an object', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1200,7 +1202,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add where not wrapped clause', async (assert) => {
+ test('add where not wrapped clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1237,7 +1239,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('wrap where not wrapped clause', async (assert) => {
+ test('wrap where not wrapped clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1280,7 +1282,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add where not clause with operator', async (assert) => {
+ test('add where not clause with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1314,7 +1316,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('wrap where not clause with operator', async (assert) => {
+ test('wrap where not clause with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1357,7 +1359,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add where not clause as a raw query', async (assert) => {
+ test('add where not clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1402,7 +1404,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add where not clause as a raw builder query', async (assert) => {
+ test('add where not clause as a raw builder query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1439,7 +1441,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add orWhereNot clause', async (assert) => {
+ test('add orWhereNot clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1480,7 +1482,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('wrap orWhereNot clause', async (assert) => {
+ test('wrap orWhereNot clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1523,7 +1525,7 @@ test.group('Query Builder | whereNot', (group) => {
await connection.disconnect()
})
- test('add orWhereNot wrapped clause', async (assert) => {
+ test('add orWhereNot wrapped clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1576,22 +1578,22 @@ test.group('Query Builder | whereNot', (group) => {
})
test.group('Query Builder | whereIn', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add whereIn clause', async (assert) => {
+ test('add whereIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1624,7 +1626,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('wrap whereIn clause', async (assert) => {
+ test('wrap whereIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1666,7 +1668,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a query callback', async (assert) => {
+ test('add whereIn as a query callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1710,7 +1712,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('wrap whereIn as a query callback', async (assert) => {
+ test('wrap whereIn as a query callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1764,7 +1766,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a subquery', async (assert) => {
+ test('add whereIn as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1806,7 +1808,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a rawquery inside array', async (assert) => {
+ test('add whereIn as a rawquery inside array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1857,7 +1859,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('wrap whereIn as a rawquery inside array', async (assert) => {
+ test('wrap whereIn as a rawquery inside array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1920,7 +1922,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a rawquery', async (assert) => {
+ test('add whereIn as a rawquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -1973,7 +1975,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a raw builder query', async (assert) => {
+ test('add whereIn as a raw builder query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2014,7 +2016,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a subquery with array of keys', async (assert) => {
+ test('add whereIn as a subquery with array of keys', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2067,7 +2069,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add whereIn as a 2d array', async (assert) => {
+ test('add whereIn as a 2d array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2104,7 +2106,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add orWhereIn clause', async (assert) => {
+ test('add orWhereIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2145,7 +2147,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('wrap orWhereIn clause', async (assert) => {
+ test('wrap orWhereIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2188,7 +2190,7 @@ test.group('Query Builder | whereIn', (group) => {
await connection.disconnect()
})
- test('add orWhereIn as a query callback', async (assert) => {
+ test('add orWhereIn as a query callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2247,22 +2249,22 @@ test.group('Query Builder | whereIn', (group) => {
})
test.group('Query Builder | whereNotIn', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add whereNotIn clause', async (assert) => {
+ test('add whereNotIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2295,7 +2297,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('wrap whereNotIn clause', async (assert) => {
+ test('wrap whereNotIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2337,7 +2339,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('add whereNotIn as a query callback', async (assert) => {
+ test('add whereNotIn as a query callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2381,7 +2383,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('add whereNotIn as a sub query', async (assert) => {
+ test('add whereNotIn as a sub query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2423,7 +2425,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('wrap whereNotIn as a sub query', async (assert) => {
+ test('wrap whereNotIn as a sub query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2475,7 +2477,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('add whereNotIn as a 2d array', async (assert) => {
+ test('add whereNotIn as a 2d array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2512,7 +2514,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('add orWhereNotIn clause', async (assert) => {
+ test('add orWhereNotIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2553,7 +2555,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('wrap orWhereNotIn clause', async (assert) => {
+ test('wrap orWhereNotIn clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2596,7 +2598,7 @@ test.group('Query Builder | whereNotIn', (group) => {
await connection.disconnect()
})
- test('add orWhereNotIn as a subquery', async (assert) => {
+ test('add orWhereNotIn as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2655,22 +2657,22 @@ test.group('Query Builder | whereNotIn', (group) => {
})
test.group('Query Builder | whereNull', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where null clause', async (assert) => {
+ test('add where null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2704,7 +2706,7 @@ test.group('Query Builder | whereNull', (group) => {
await connection.disconnect()
})
- test('wrap where null clause', async (assert) => {
+ test('wrap where null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2747,7 +2749,7 @@ test.group('Query Builder | whereNull', (group) => {
await connection.disconnect()
})
- test('add or where null clause', async (assert) => {
+ test('add or where null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2790,22 +2792,22 @@ test.group('Query Builder | whereNull', (group) => {
})
test.group('Query Builder | whereNotNull', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where not null clause', async (assert) => {
+ test('add where not null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2839,7 +2841,7 @@ test.group('Query Builder | whereNotNull', (group) => {
await connection.disconnect()
})
- test('wrap where not null clause', async (assert) => {
+ test('wrap where not null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2882,7 +2884,7 @@ test.group('Query Builder | whereNotNull', (group) => {
await connection.disconnect()
})
- test('add or where not null clause', async (assert) => {
+ test('add or where not null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2925,22 +2927,22 @@ test.group('Query Builder | whereNotNull', (group) => {
})
test.group('Query Builder | whereExists', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where exists clause', async (assert) => {
+ test('add where exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2964,7 +2966,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('wrap where exists clause', async (assert) => {
+ test('wrap where exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -2993,7 +2995,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('add where exists clause as a subquery', async (assert) => {
+ test('add where exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3014,7 +3016,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('wrap where exists clause as a subquery', async (assert) => {
+ test('wrap where exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3038,7 +3040,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('wrap subquery', async (assert) => {
+ test('wrap subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3073,7 +3075,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('add where exists clause as a raw query', async (assert) => {
+ test('add where exists clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3094,7 +3096,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('add or where exists clause', async (assert) => {
+ test('add or where exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3119,7 +3121,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('wrap or where exists clause', async (assert) => {
+ test('wrap or where exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3155,7 +3157,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('add or where exists clause as a subquery', async (assert) => {
+ test('add or where exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3176,7 +3178,7 @@ test.group('Query Builder | whereExists', (group) => {
await connection.disconnect()
})
- test('wrap or where exists clause as a subquery', async (assert) => {
+ test('wrap or where exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3202,22 +3204,22 @@ test.group('Query Builder | whereExists', (group) => {
})
test.group('Query Builder | whereNotExists', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where not exists clause', async (assert) => {
+ test('add where not exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3242,7 +3244,7 @@ test.group('Query Builder | whereNotExists', (group) => {
await connection.disconnect()
})
- test('wrap where not exists clause', async (assert) => {
+ test('wrap where not exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3272,7 +3274,7 @@ test.group('Query Builder | whereNotExists', (group) => {
await connection.disconnect()
})
- test('add where not exists clause as a subquery', async (assert) => {
+ test('add where not exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3293,7 +3295,7 @@ test.group('Query Builder | whereNotExists', (group) => {
await connection.disconnect()
})
- test('add or where not exists clause', async (assert) => {
+ test('add or where not exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3318,7 +3320,7 @@ test.group('Query Builder | whereNotExists', (group) => {
await connection.disconnect()
})
- test('wrap or where not exists clause', async (assert) => {
+ test('wrap or where not exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3354,7 +3356,7 @@ test.group('Query Builder | whereNotExists', (group) => {
await connection.disconnect()
})
- test('add or where not exists clause as a subquery', async (assert) => {
+ test('add or where not exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3377,22 +3379,22 @@ test.group('Query Builder | whereNotExists', (group) => {
})
test.group('Query Builder | whereBetween', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where between clause', async (assert) => {
+ test('add where between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3426,7 +3428,7 @@ test.group('Query Builder | whereBetween', (group) => {
await connection.disconnect()
})
- test('wrap where between clause', async (assert) => {
+ test('wrap where between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3469,7 +3471,7 @@ test.group('Query Builder | whereBetween', (group) => {
await connection.disconnect()
})
- test('add where between clause as a raw query', async (assert) => {
+ test('add where between clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3518,7 +3520,7 @@ test.group('Query Builder | whereBetween', (group) => {
await connection.disconnect()
})
- test('add or where between clause', async (assert) => {
+ test('add or where between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3552,7 +3554,7 @@ test.group('Query Builder | whereBetween', (group) => {
await connection.disconnect()
})
- test('wrap or where between clause', async (assert) => {
+ test('wrap or where between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3597,7 +3599,7 @@ test.group('Query Builder | whereBetween', (group) => {
await connection.disconnect()
})
- test('add or where between clause as a raw query', async (assert) => {
+ test('add or where between clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3648,22 +3650,22 @@ test.group('Query Builder | whereBetween', (group) => {
})
test.group('Query Builder | whereNotBetween', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where not between clause', async (assert) => {
+ test('add where not between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3697,7 +3699,7 @@ test.group('Query Builder | whereNotBetween', (group) => {
await connection.disconnect()
})
- test('wrap where not between clause', async (assert) => {
+ test('wrap where not between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3740,7 +3742,7 @@ test.group('Query Builder | whereNotBetween', (group) => {
await connection.disconnect()
})
- test('add where not between clause as a raw query', async (assert) => {
+ test('add where not between clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3789,7 +3791,7 @@ test.group('Query Builder | whereNotBetween', (group) => {
await connection.disconnect()
})
- test('add or where not between clause', async (assert) => {
+ test('add or where not between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3832,7 +3834,7 @@ test.group('Query Builder | whereNotBetween', (group) => {
await connection.disconnect()
})
- test('add or where not between clause as a raw query', async (assert) => {
+ test('add or where not between clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3883,22 +3885,22 @@ test.group('Query Builder | whereNotBetween', (group) => {
})
test.group('Query Builder | whereRaw', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where raw clause', async (assert) => {
+ test('add where raw clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3916,7 +3918,7 @@ test.group('Query Builder | whereRaw', (group) => {
await connection.disconnect()
})
- test('wrap where raw clause', async (assert) => {
+ test('wrap where raw clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3940,7 +3942,7 @@ test.group('Query Builder | whereRaw', (group) => {
await connection.disconnect()
})
- test('add where raw clause without bindings', async (assert) => {
+ test('add where raw clause without bindings', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3958,7 +3960,7 @@ test.group('Query Builder | whereRaw', (group) => {
await connection.disconnect()
})
- test('add where raw clause with object of bindings', async (assert) => {
+ test('add where raw clause with object of bindings', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3975,7 +3977,7 @@ test.group('Query Builder | whereRaw', (group) => {
await connection.disconnect()
})
- test('add where raw clause from a raw query', async (assert) => {
+ test('add where raw clause from a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -3996,7 +3998,7 @@ test.group('Query Builder | whereRaw', (group) => {
await connection.disconnect()
})
- test('add or where raw clause', async (assert) => {
+ test('add or where raw clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4019,7 +4021,7 @@ test.group('Query Builder | whereRaw', (group) => {
await connection.disconnect()
})
- test('wrap or where raw clause', async (assert) => {
+ test('wrap or where raw clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4045,22 +4047,22 @@ test.group('Query Builder | whereRaw', (group) => {
})
test.group('Query Builder | join', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query join', async (assert) => {
+ test('add query join', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4081,7 +4083,7 @@ test.group('Query Builder | join', (group) => {
await connection.disconnect()
})
- test('add query join with operator', async (assert) => {
+ test('add query join with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4102,7 +4104,7 @@ test.group('Query Builder | join', (group) => {
await connection.disconnect()
})
- test('add query join using join callback', async (assert) => {
+ test('add query join using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4127,7 +4129,7 @@ test.group('Query Builder | join', (group) => {
await connection.disconnect()
})
- test('add query join as a raw query', async (assert) => {
+ test('add query join as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4152,7 +4154,7 @@ test.group('Query Builder | join', (group) => {
await connection.disconnect()
})
- test('add query join as a raw builder query', async (assert) => {
+ test('add query join as a raw builder query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4175,22 +4177,22 @@ test.group('Query Builder | join', (group) => {
})
test.group('Query Builder | innerJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query innerJoin', async (assert) => {
+ test('add query innerJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4211,7 +4213,7 @@ test.group('Query Builder | innerJoin', (group) => {
await connection.disconnect()
})
- test('add query innerJoin with operator', async (assert) => {
+ test('add query innerJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4232,7 +4234,7 @@ test.group('Query Builder | innerJoin', (group) => {
await connection.disconnect()
})
- test('add query innerJoin using join callback', async (assert) => {
+ test('add query innerJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4257,7 +4259,7 @@ test.group('Query Builder | innerJoin', (group) => {
await connection.disconnect()
})
- test('add query innerJoin as a raw query', async (assert) => {
+ test('add query innerJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4282,7 +4284,7 @@ test.group('Query Builder | innerJoin', (group) => {
await connection.disconnect()
})
- test('add query innerJoin as a raw query', async (assert) => {
+ test('add query innerJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4305,22 +4307,22 @@ test.group('Query Builder | innerJoin', (group) => {
})
test.group('Query Builder | leftJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query leftJoin', async (assert) => {
+ test('add query leftJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4341,7 +4343,7 @@ test.group('Query Builder | leftJoin', (group) => {
await connection.disconnect()
})
- test('add query leftJoin with operator', async (assert) => {
+ test('add query leftJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4362,7 +4364,7 @@ test.group('Query Builder | leftJoin', (group) => {
await connection.disconnect()
})
- test('add query leftJoin using join callback', async (assert) => {
+ test('add query leftJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4387,7 +4389,7 @@ test.group('Query Builder | leftJoin', (group) => {
await connection.disconnect()
})
- test('add query leftJoin as a raw query', async (assert) => {
+ test('add query leftJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4414,22 +4416,22 @@ test.group('Query Builder | leftJoin', (group) => {
})
test.group('Query Builder | leftOuterJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query leftOuterJoin', async (assert) => {
+ test('add query leftOuterJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4450,7 +4452,7 @@ test.group('Query Builder | leftOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query leftOuterJoin with operator', async (assert) => {
+ test('add query leftOuterJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4471,7 +4473,7 @@ test.group('Query Builder | leftOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query leftOuterJoin using join callback', async (assert) => {
+ test('add query leftOuterJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4496,7 +4498,7 @@ test.group('Query Builder | leftOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query leftOuterJoin as a raw query', async (assert) => {
+ test('add query leftOuterJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4523,22 +4525,22 @@ test.group('Query Builder | leftOuterJoin', (group) => {
})
test.group('Query Builder | rightJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query rightJoin', async (assert) => {
+ test('add query rightJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4559,7 +4561,7 @@ test.group('Query Builder | rightJoin', (group) => {
await connection.disconnect()
})
- test('add query rightJoin with operator', async (assert) => {
+ test('add query rightJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4580,7 +4582,7 @@ test.group('Query Builder | rightJoin', (group) => {
await connection.disconnect()
})
- test('add query rightJoin using join callback', async (assert) => {
+ test('add query rightJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4605,7 +4607,7 @@ test.group('Query Builder | rightJoin', (group) => {
await connection.disconnect()
})
- test('add query rightJoin as a raw query', async (assert) => {
+ test('add query rightJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4632,22 +4634,22 @@ test.group('Query Builder | rightJoin', (group) => {
})
test.group('Query Builder | rightOuterJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query rightOuterJoin', async (assert) => {
+ test('add query rightOuterJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4668,7 +4670,7 @@ test.group('Query Builder | rightOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query rightOuterJoin with operator', async (assert) => {
+ test('add query rightOuterJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4689,7 +4691,7 @@ test.group('Query Builder | rightOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query rightOuterJoin using join callback', async (assert) => {
+ test('add query rightOuterJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4714,7 +4716,7 @@ test.group('Query Builder | rightOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query rightOuterJoin as a raw query', async (assert) => {
+ test('add query rightOuterJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4741,22 +4743,22 @@ test.group('Query Builder | rightOuterJoin', (group) => {
})
test.group('Query Builder | fullOuterJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query fullOuterJoin', async (assert) => {
+ test('add query fullOuterJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4777,7 +4779,7 @@ test.group('Query Builder | fullOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query fullOuterJoin with operator', async (assert) => {
+ test('add query fullOuterJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4798,7 +4800,7 @@ test.group('Query Builder | fullOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query fullOuterJoin using join callback', async (assert) => {
+ test('add query fullOuterJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4823,7 +4825,7 @@ test.group('Query Builder | fullOuterJoin', (group) => {
await connection.disconnect()
})
- test('add query fullOuterJoin as a raw query', async (assert) => {
+ test('add query fullOuterJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4850,22 +4852,22 @@ test.group('Query Builder | fullOuterJoin', (group) => {
})
test.group('Query Builder | crossJoin', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add query crossJoin', async (assert) => {
+ test('add query crossJoin', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4886,7 +4888,7 @@ test.group('Query Builder | crossJoin', (group) => {
await connection.disconnect()
})
- test('add query crossJoin with operator', async (assert) => {
+ test('add query crossJoin with operator', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4907,7 +4909,7 @@ test.group('Query Builder | crossJoin', (group) => {
await connection.disconnect()
})
- test('add query crossJoin using join callback', async (assert) => {
+ test('add query crossJoin using join callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4932,7 +4934,7 @@ test.group('Query Builder | crossJoin', (group) => {
await connection.disconnect()
})
- test('add query crossJoin as a raw query', async (assert) => {
+ test('add query crossJoin as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4959,22 +4961,22 @@ test.group('Query Builder | crossJoin', (group) => {
})
test.group('Query Builder | joinRaw', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add join as a raw join', async (assert) => {
+ test('add join as a raw join', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -4992,7 +4994,7 @@ test.group('Query Builder | joinRaw', (group) => {
await connection.disconnect()
})
- test('add join as a raw join by passing the raw query output', async (assert) => {
+ test('add join as a raw join by passing the raw query output', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5015,22 +5017,22 @@ test.group('Query Builder | joinRaw', (group) => {
})
test.group('Query Builder | distinct', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define distinct columns', async (assert) => {
+ test('define distinct columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5066,23 +5068,23 @@ test.group('Query Builder | distinct', (group) => {
})
test.group('Query Builder | distinctOn', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
if (process.env.DB === 'pg') {
- test('define distinct columns', async (assert) => {
+ test('define distinct columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5119,22 +5121,22 @@ test.group('Query Builder | distinctOn', (group) => {
})
test.group('Query Builder | groupBy', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define group by columns', async (assert) => {
+ test('define group by columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5170,22 +5172,22 @@ test.group('Query Builder | groupBy', (group) => {
})
test.group('Query Builder | groupByRaw', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define group by columns as a raw query', async (assert) => {
+ test('define group by columns as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5205,22 +5207,22 @@ test.group('Query Builder | groupByRaw', (group) => {
})
test.group('Query Builder | orderBy', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define order by columns', async (assert) => {
+ test('define order by columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5254,7 +5256,7 @@ test.group('Query Builder | orderBy', (group) => {
await connection.disconnect()
})
- test('define order by columns with explicit direction', async (assert) => {
+ test('define order by columns with explicit direction', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5288,7 +5290,7 @@ test.group('Query Builder | orderBy', (group) => {
await connection.disconnect()
})
- test('define order by columns as an array', async (assert) => {
+ test('define order by columns as an array', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5322,7 +5324,7 @@ test.group('Query Builder | orderBy', (group) => {
await connection.disconnect()
})
- test('define order by columns as an array of objects', async (assert) => {
+ test('define order by columns as an array of objects', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5371,7 +5373,7 @@ test.group('Query Builder | orderBy', (group) => {
await connection.disconnect()
})
- test('define order by columns as subquery', async (assert) => {
+ test('define order by columns as subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5402,7 +5404,7 @@ test.group('Query Builder | orderBy', (group) => {
await connection.disconnect()
})
- test('define order by columns as an array of subqueries', async (assert) => {
+ test('define order by columns as an array of subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5441,22 +5443,22 @@ test.group('Query Builder | orderBy', (group) => {
})
test.group('Query Builder | orderByRaw', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define order by columns as a raw query', async (assert) => {
+ test('define order by columns as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5474,22 +5476,22 @@ test.group('Query Builder | orderByRaw', (group) => {
})
test.group('Query Builder | offset', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define select offset', async (assert) => {
+ test('define select offset', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5509,22 +5511,22 @@ test.group('Query Builder | offset', (group) => {
})
test.group('Query Builder | limit', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define results limit', async (assert) => {
+ test('define results limit', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5544,22 +5546,22 @@ test.group('Query Builder | limit', (group) => {
})
test.group('Query Builder | union', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define union query as a callback', async (assert) => {
+ test('define union query as a callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5584,7 +5586,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('define union query as a subquery', async (assert) => {
+ test('define union query as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5605,7 +5607,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('define union query as a raw query', async (assert) => {
+ test('define union query as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5631,7 +5633,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('define union query as an array of callbacks', async (assert) => {
+ test('define union query as an array of callbacks', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5660,7 +5662,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('define union query as an array of subqueries', async (assert) => {
+ test('define union query as an array of subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5683,7 +5685,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('define union query as an array of raw queries', async (assert) => {
+ test('define union query as an array of raw queries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5709,7 +5711,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('add limit to union set', async (assert) => {
+ test('add limit to union set', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5764,7 +5766,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('add limit to union subquery', async (assert) => {
+ test('add limit to union subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5823,7 +5825,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('count union set', async (assert) => {
+ test('count union set', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5873,7 +5875,7 @@ test.group('Query Builder | union', (group) => {
await connection.disconnect()
})
- test('count union set with limit on subquery', async (assert) => {
+ test('count union set with limit on subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5927,22 +5929,22 @@ test.group('Query Builder | union', (group) => {
})
test.group('Query Builder | unionAll', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define unionAll query as a callback', async (assert) => {
+ test('define unionAll query as a callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5967,7 +5969,7 @@ test.group('Query Builder | unionAll', (group) => {
await connection.disconnect()
})
- test('define unionAll query as a subquery', async (assert) => {
+ test('define unionAll query as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -5990,7 +5992,7 @@ test.group('Query Builder | unionAll', (group) => {
await connection.disconnect()
})
- test('define unionAll query as a raw query', async (assert) => {
+ test('define unionAll query as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6016,7 +6018,7 @@ test.group('Query Builder | unionAll', (group) => {
await connection.disconnect()
})
- test('define unionAll query as an array of callbacks', async (assert) => {
+ test('define unionAll query as an array of callbacks', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6045,7 +6047,7 @@ test.group('Query Builder | unionAll', (group) => {
await connection.disconnect()
})
- test('define unionAll query as an array of subqueries', async (assert) => {
+ test('define unionAll query as an array of subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6068,7 +6070,7 @@ test.group('Query Builder | unionAll', (group) => {
await connection.disconnect()
})
- test('define unionAll query as an array of raw queries', async (assert) => {
+ test('define unionAll query as an array of raw queries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6094,22 +6096,22 @@ test.group('Query Builder | unionAll', (group) => {
})
test.group('Query Builder | forUpdate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define FOR UPDATE lock', async (assert) => {
+ test('define FOR UPDATE lock', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6127,7 +6129,7 @@ test.group('Query Builder | forUpdate', (group) => {
await connection.disconnect()
})
- test('define FOR UPDATE lock with additional tables (pg only)', async (assert) => {
+ test('define FOR UPDATE lock with additional tables (pg only)', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6147,22 +6149,22 @@ test.group('Query Builder | forUpdate', (group) => {
})
test.group('Query Builder | forShare', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define FOR SHARE lock', async (assert) => {
+ test('define FOR SHARE lock', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6180,7 +6182,7 @@ test.group('Query Builder | forShare', (group) => {
await connection.disconnect()
})
- test('define FOR SHARE lock with additional tables (pg only)', async (assert) => {
+ test('define FOR SHARE lock with additional tables (pg only)', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6201,20 +6203,20 @@ test.group('Query Builder | forShare', (group) => {
if (['pg', 'mysql'].includes(process.env.DB!)) {
test.group('Query Builder | noWait', (group) => {
- group.before(async () => {
+ group.setup(async () => {
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add no wait instruction to the query', async (assert) => {
+ test('add no wait instruction to the query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6235,15 +6237,15 @@ if (['pg', 'mysql'].includes(process.env.DB!)) {
})
test.group('Query Builder | skipLocked', (group) => {
- group.before(async () => {
+ group.setup(async () => {
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
})
- test('add skip locked instruction to the query', async (assert) => {
+ test('add skip locked instruction to the query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6265,22 +6267,22 @@ if (['pg', 'mysql'].includes(process.env.DB!)) {
}
test.group('Query Builder | having', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having clause', async (assert) => {
+ test('add having clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6314,7 +6316,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add having clause as a callback', async (assert) => {
+ test('add having clause as a callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6359,7 +6361,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add having clause value being a raw query', async (assert) => {
+ test('add having clause value being a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const ref = connection.client!.ref.bind(connection.client!)
@@ -6419,7 +6421,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add having clause value being a sub query', async (assert) => {
+ test('add having clause value being a sub query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6464,7 +6466,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add having clause as a raw query', async (assert) => {
+ test('add having clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6486,7 +6488,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add having clause as a raw query', async (assert) => {
+ test('add having clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6507,7 +6509,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add having clause as a raw builder query', async (assert) => {
+ test('add having clause as a raw builder query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6528,7 +6530,7 @@ test.group('Query Builder | having', (group) => {
await connection.disconnect()
})
- test('add or having clause', async (assert) => {
+ test('add or having clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6571,22 +6573,22 @@ test.group('Query Builder | having', (group) => {
})
test.group('Query Builder | havingIn', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having in clause', async (assert) => {
+ test('add having in clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6620,7 +6622,7 @@ test.group('Query Builder | havingIn', (group) => {
await connection.disconnect()
})
- test('add having in clause values as subqueries', async (assert) => {
+ test('add having in clause values as subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6661,7 +6663,7 @@ test.group('Query Builder | havingIn', (group) => {
await connection.disconnect()
})
- test('add having in clause values as raw queries', async (assert) => {
+ test('add having in clause values as raw queries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6702,7 +6704,7 @@ test.group('Query Builder | havingIn', (group) => {
await connection.disconnect()
})
- test('add having in clause values as query callbacks', async (assert) => {
+ test('add having in clause values as query callbacks', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6743,7 +6745,7 @@ test.group('Query Builder | havingIn', (group) => {
await connection.disconnect()
})
- test('add or having in clause', async (assert) => {
+ test('add or having in clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6786,22 +6788,22 @@ test.group('Query Builder | havingIn', (group) => {
})
test.group('Query Builder | havingNotIn', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add not having in clause', async (assert) => {
+ test('add not having in clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6835,7 +6837,7 @@ test.group('Query Builder | havingNotIn', (group) => {
await connection.disconnect()
})
- test('add having in clause values as subqueries', async (assert) => {
+ test('add having in clause values as subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6876,7 +6878,7 @@ test.group('Query Builder | havingNotIn', (group) => {
await connection.disconnect()
})
- test('add having in clause values as raw queries', async (assert) => {
+ test('add having in clause values as raw queries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6917,7 +6919,7 @@ test.group('Query Builder | havingNotIn', (group) => {
await connection.disconnect()
})
- test('add having in clause values as query callbacks', async (assert) => {
+ test('add having in clause values as query callbacks', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -6959,7 +6961,7 @@ test.group('Query Builder | havingNotIn', (group) => {
await connection.disconnect()
})
- test('add or having in clause', async (assert) => {
+ test('add or having in clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7001,22 +7003,22 @@ test.group('Query Builder | havingNotIn', (group) => {
})
test.group('Query Builder | havingNull', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having null clause', async (assert) => {
+ test('add having null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7050,7 +7052,7 @@ test.group('Query Builder | havingNull', (group) => {
await connection.disconnect()
})
- test('add or having null clause', async (assert) => {
+ test('add or having null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7093,22 +7095,22 @@ test.group('Query Builder | havingNull', (group) => {
})
test.group('Query Builder | havingNotNull', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having null clause', async (assert) => {
+ test('add having null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7142,7 +7144,7 @@ test.group('Query Builder | havingNotNull', (group) => {
await connection.disconnect()
})
- test('add or having not null clause', async (assert) => {
+ test('add or having not null clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7185,22 +7187,22 @@ test.group('Query Builder | havingNotNull', (group) => {
})
test.group('Query Builder | havingExists', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having exists clause', async (assert) => {
+ test('add having exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7224,7 +7226,7 @@ test.group('Query Builder | havingExists', (group) => {
await connection.disconnect()
})
- test('add having exists clause as a subquery', async (assert) => {
+ test('add having exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7245,7 +7247,7 @@ test.group('Query Builder | havingExists', (group) => {
await connection.disconnect()
})
- test('add or having exists clause', async (assert) => {
+ test('add or having exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7278,22 +7280,22 @@ test.group('Query Builder | havingExists', (group) => {
})
test.group('Query Builder | havingNotExists', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having not exists clause', async (assert) => {
+ test('add having not exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7318,7 +7320,7 @@ test.group('Query Builder | havingNotExists', (group) => {
await connection.disconnect()
})
- test('add having not exists clause as a subquery', async (assert) => {
+ test('add having not exists clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7341,7 +7343,7 @@ test.group('Query Builder | havingNotExists', (group) => {
await connection.disconnect()
})
- test('add or having not exists clause', async (assert) => {
+ test('add or having not exists clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7374,22 +7376,22 @@ test.group('Query Builder | havingNotExists', (group) => {
})
test.group('Query Builder | havingBetween', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having between clause', async (assert) => {
+ test('add having between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7423,7 +7425,7 @@ test.group('Query Builder | havingBetween', (group) => {
await connection.disconnect()
})
- test('add having between clause with raw values', async (assert) => {
+ test('add having between clause with raw values', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7472,7 +7474,7 @@ test.group('Query Builder | havingBetween', (group) => {
await connection.disconnect()
})
- test('add having between clause with subqueries', async (assert) => {
+ test('add having between clause with subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7521,7 +7523,7 @@ test.group('Query Builder | havingBetween', (group) => {
await connection.disconnect()
})
- test('add or having between clause', async (assert) => {
+ test('add or having between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7564,22 +7566,22 @@ test.group('Query Builder | havingBetween', (group) => {
})
test.group('Query Builder | havingNotBetween', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having not between clause', async (assert) => {
+ test('add having not between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7613,7 +7615,7 @@ test.group('Query Builder | havingNotBetween', (group) => {
await connection.disconnect()
})
- test('add having not between clause with raw values', async (assert) => {
+ test('add having not between clause with raw values', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7662,7 +7664,7 @@ test.group('Query Builder | havingNotBetween', (group) => {
await connection.disconnect()
})
- test('add having not between clause with subqueries', async (assert) => {
+ test('add having not between clause with subqueries', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7711,7 +7713,7 @@ test.group('Query Builder | havingNotBetween', (group) => {
await connection.disconnect()
})
- test('add or having not between clause', async (assert) => {
+ test('add or having not between clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7754,22 +7756,22 @@ test.group('Query Builder | havingNotBetween', (group) => {
})
test.group('Query Builder | havingRaw', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add having raw clause', async (assert) => {
+ test('add having raw clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7787,7 +7789,7 @@ test.group('Query Builder | havingRaw', (group) => {
await connection.disconnect()
})
- test('add having raw clause without bindings', async (assert) => {
+ test('add having raw clause without bindings', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7804,7 +7806,7 @@ test.group('Query Builder | havingRaw', (group) => {
await connection.disconnect()
})
- test('add having raw clause with object of bindings', async (assert) => {
+ test('add having raw clause with object of bindings', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7822,7 +7824,7 @@ test.group('Query Builder | havingRaw', (group) => {
await connection.disconnect()
})
- test('add having raw clause from a raw query', async (assert) => {
+ test('add having raw clause from a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7843,7 +7845,7 @@ test.group('Query Builder | havingRaw', (group) => {
await connection.disconnect()
})
- test('add or having raw clause', async (assert) => {
+ test('add or having raw clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7868,22 +7870,22 @@ test.group('Query Builder | havingRaw', (group) => {
})
test.group('Query Builder | clearSelect', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clear selected columns', async (assert) => {
+ test('clear selected columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7904,22 +7906,22 @@ test.group('Query Builder | clearSelect', (group) => {
})
test.group('Query Builder | clearWhere', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clear where clauses', async (assert) => {
+ test('clear where clauses', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7940,22 +7942,22 @@ test.group('Query Builder | clearWhere', (group) => {
})
test.group('Query Builder | clearOrder', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clear order by columns', async (assert) => {
+ test('clear order by columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -7976,22 +7978,22 @@ test.group('Query Builder | clearOrder', (group) => {
})
test.group('Query Builder | clearHaving', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clear having clause', async (assert) => {
+ test('clear having clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8012,22 +8014,22 @@ test.group('Query Builder | clearHaving', (group) => {
})
test.group('Query Builder | clearLimit', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clear limit', async (assert) => {
+ test('clear limit', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8044,22 +8046,22 @@ test.group('Query Builder | clearLimit', (group) => {
})
test.group('Query Builder | clearOffset', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clear offset', async (assert) => {
+ test('clear offset', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8076,22 +8078,22 @@ test.group('Query Builder | clearOffset', (group) => {
})
test.group('Query Builder | count', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('count all rows', async (assert) => {
+ test('count all rows', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8125,7 +8127,7 @@ test.group('Query Builder | count', (group) => {
await connection.disconnect()
})
- test('count multiple rows', async (assert) => {
+ test('count multiple rows', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8159,7 +8161,7 @@ test.group('Query Builder | count', (group) => {
await connection.disconnect()
})
- test('count by raw query', async (assert) => {
+ test('count by raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8214,7 +8216,7 @@ test.group('Query Builder | count', (group) => {
await connection.disconnect()
})
- test('count by subquery', async (assert) => {
+ test('count by subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8265,7 +8267,7 @@ test.group('Query Builder | count', (group) => {
await connection.disconnect()
})
- test('count by raw query on multiple columns', async (assert) => {
+ test('count by raw query on multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8322,7 +8324,7 @@ test.group('Query Builder | count', (group) => {
await connection.disconnect()
})
- test('count by subquery on multiple columns', async (assert) => {
+ test('count by subquery on multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8377,22 +8379,22 @@ test.group('Query Builder | count', (group) => {
})
test.group('Query Builder | countDistinct', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('count all rows', async (assert) => {
+ test('count all rows', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8426,7 +8428,7 @@ test.group('Query Builder | countDistinct', (group) => {
await connection.disconnect()
})
- test('count multiple rows', async (assert) => {
+ test('count multiple rows', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8460,7 +8462,7 @@ test.group('Query Builder | countDistinct', (group) => {
await connection.disconnect()
})
- test('count by raw query', async (assert) => {
+ test('count by raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8515,7 +8517,7 @@ test.group('Query Builder | countDistinct', (group) => {
await connection.disconnect()
})
- test('count by subquery', async (assert) => {
+ test('count by subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8566,7 +8568,7 @@ test.group('Query Builder | countDistinct', (group) => {
await connection.disconnect()
})
- test('count by raw query on multiple columns', async (assert) => {
+ test('count by raw query on multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8623,7 +8625,7 @@ test.group('Query Builder | countDistinct', (group) => {
await connection.disconnect()
})
- test('count by subquery on multiple columns', async (assert) => {
+ test('count by subquery on multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8678,22 +8680,22 @@ test.group('Query Builder | countDistinct', (group) => {
})
test.group('Query Builder | min', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use min function', async (assert) => {
+ test('use min function', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8727,7 +8729,7 @@ test.group('Query Builder | min', (group) => {
await connection.disconnect()
})
- test('use min function for multiple times', async (assert) => {
+ test('use min function for multiple times', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8761,7 +8763,7 @@ test.group('Query Builder | min', (group) => {
await connection.disconnect()
})
- test('use raw queries to compute min', async (assert) => {
+ test('use raw queries to compute min', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8816,7 +8818,7 @@ test.group('Query Builder | min', (group) => {
await connection.disconnect()
})
- test('use subqueries to compute min', async (assert) => {
+ test('use subqueries to compute min', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8867,7 +8869,7 @@ test.group('Query Builder | min', (group) => {
await connection.disconnect()
})
- test('use raw query to compute min with multiple columns', async (assert) => {
+ test('use raw query to compute min with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8924,7 +8926,7 @@ test.group('Query Builder | min', (group) => {
await connection.disconnect()
})
- test('use subquery to compute min with multiple columns', async (assert) => {
+ test('use subquery to compute min with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -8978,22 +8980,22 @@ test.group('Query Builder | min', (group) => {
})
test.group('Query Builder | max', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use max function', async (assert) => {
+ test('use max function', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9027,7 +9029,7 @@ test.group('Query Builder | max', (group) => {
await connection.disconnect()
})
- test('use max function for multiple times', async (assert) => {
+ test('use max function for multiple times', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9061,7 +9063,7 @@ test.group('Query Builder | max', (group) => {
await connection.disconnect()
})
- test('use raw queries to compute max', async (assert) => {
+ test('use raw queries to compute max', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9116,7 +9118,7 @@ test.group('Query Builder | max', (group) => {
await connection.disconnect()
})
- test('use subqueries to compute max', async (assert) => {
+ test('use subqueries to compute max', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9167,7 +9169,7 @@ test.group('Query Builder | max', (group) => {
await connection.disconnect()
})
- test('use raw query to compute max with multiple columns', async (assert) => {
+ test('use raw query to compute max with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9224,7 +9226,7 @@ test.group('Query Builder | max', (group) => {
await connection.disconnect()
})
- test('use subquery to compute max with multiple columns', async (assert) => {
+ test('use subquery to compute max with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9279,22 +9281,22 @@ test.group('Query Builder | max', (group) => {
})
test.group('Query Builder | sum', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use sum function', async (assert) => {
+ test('use sum function', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9328,7 +9330,7 @@ test.group('Query Builder | sum', (group) => {
await connection.disconnect()
})
- test('use sum function for multiple times', async (assert) => {
+ test('use sum function for multiple times', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9362,7 +9364,7 @@ test.group('Query Builder | sum', (group) => {
await connection.disconnect()
})
- test('use raw queries to compute sum', async (assert) => {
+ test('use raw queries to compute sum', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9417,7 +9419,7 @@ test.group('Query Builder | sum', (group) => {
await connection.disconnect()
})
- test('use subqueries to compute sum', async (assert) => {
+ test('use subqueries to compute sum', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9468,7 +9470,7 @@ test.group('Query Builder | sum', (group) => {
await connection.disconnect()
})
- test('use raw query to compute sum with multiple columns', async (assert) => {
+ test('use raw query to compute sum with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9525,7 +9527,7 @@ test.group('Query Builder | sum', (group) => {
await connection.disconnect()
})
- test('use subquery to compute sum with multiple columns', async (assert) => {
+ test('use subquery to compute sum with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9579,22 +9581,22 @@ test.group('Query Builder | sum', (group) => {
})
test.group('Query Builder | sumDistinct', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use sumDistinct function', async (assert) => {
+ test('use sumDistinct function', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9628,7 +9630,7 @@ test.group('Query Builder | sumDistinct', (group) => {
await connection.disconnect()
})
- test('use sumDistinct function for multiple times', async (assert) => {
+ test('use sumDistinct function for multiple times', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9662,7 +9664,7 @@ test.group('Query Builder | sumDistinct', (group) => {
await connection.disconnect()
})
- test('use raw queries to compute sumDistinct', async (assert) => {
+ test('use raw queries to compute sumDistinct', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9717,7 +9719,7 @@ test.group('Query Builder | sumDistinct', (group) => {
await connection.disconnect()
})
- test('use subqueries to compute sumDistinct', async (assert) => {
+ test('use subqueries to compute sumDistinct', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9768,7 +9770,7 @@ test.group('Query Builder | sumDistinct', (group) => {
await connection.disconnect()
})
- test('use raw query to compute sumDistinct with multiple columns', async (assert) => {
+ test('use raw query to compute sumDistinct with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9825,7 +9827,7 @@ test.group('Query Builder | sumDistinct', (group) => {
await connection.disconnect()
})
- test('use subquery to compute sumDistinct with multiple columns', async (assert) => {
+ test('use subquery to compute sumDistinct with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9880,22 +9882,22 @@ test.group('Query Builder | sumDistinct', (group) => {
})
test.group('Query Builder | avg', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use avg function', async (assert) => {
+ test('use avg function', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9929,7 +9931,7 @@ test.group('Query Builder | avg', (group) => {
await connection.disconnect()
})
- test('use avg function for multiple fields', async (assert) => {
+ test('use avg function for multiple fields', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -9963,7 +9965,7 @@ test.group('Query Builder | avg', (group) => {
await connection.disconnect()
})
- test('use raw queries to compute avg', async (assert) => {
+ test('use raw queries to compute avg', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10018,7 +10020,7 @@ test.group('Query Builder | avg', (group) => {
await connection.disconnect()
})
- test('use subqueries to compute avg', async (assert) => {
+ test('use subqueries to compute avg', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10069,7 +10071,7 @@ test.group('Query Builder | avg', (group) => {
await connection.disconnect()
})
- test('use raw query to compute avg with multiple columns', async (assert) => {
+ test('use raw query to compute avg with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10126,7 +10128,7 @@ test.group('Query Builder | avg', (group) => {
await connection.disconnect()
})
- test('use subquery to compute avg with multiple columns', async (assert) => {
+ test('use subquery to compute avg with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10181,22 +10183,22 @@ test.group('Query Builder | avg', (group) => {
})
test.group('Query Builder | avgDistinct', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('use avgDistinct function', async (assert) => {
+ test('use avgDistinct function', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10230,7 +10232,7 @@ test.group('Query Builder | avgDistinct', (group) => {
await connection.disconnect()
})
- test('use avgDistinct function for multiple times', async (assert) => {
+ test('use avgDistinct function for multiple times', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10264,7 +10266,7 @@ test.group('Query Builder | avgDistinct', (group) => {
await connection.disconnect()
})
- test('use raw queries to compute avgDistinct', async (assert) => {
+ test('use raw queries to compute avgDistinct', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10319,7 +10321,7 @@ test.group('Query Builder | avgDistinct', (group) => {
await connection.disconnect()
})
- test('use subqueries to compute avgDistinct', async (assert) => {
+ test('use subqueries to compute avgDistinct', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10370,7 +10372,7 @@ test.group('Query Builder | avgDistinct', (group) => {
await connection.disconnect()
})
- test('use raw query to compute avgDistinct with multiple columns', async (assert) => {
+ test('use raw query to compute avgDistinct with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10427,7 +10429,7 @@ test.group('Query Builder | avgDistinct', (group) => {
await connection.disconnect()
})
- test('use subquery to compute avgDistinct with multiple columns', async (assert) => {
+ test('use subquery to compute avgDistinct with multiple columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10482,22 +10484,22 @@ test.group('Query Builder | avgDistinct', (group) => {
})
test.group('Query Builder | paginate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('paginate through rows', async (assert) => {
+ test('paginate through rows', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10532,7 +10534,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('paginate through rows and select columns', async (assert) => {
+ test('paginate through rows and select columns', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10567,7 +10569,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('paginate through rows when there is orderBy clause', async (assert) => {
+ test('paginate through rows when there is orderBy clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10601,7 +10603,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('paginate through rows for the last page', async (assert) => {
+ test('paginate through rows for the last page', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10636,7 +10638,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('paginate through rows with group by clause', async (assert) => {
+ test('paginate through rows with group by clause', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10676,7 +10678,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('generate range of pagination urls', async (assert) => {
+ test('generate range of pagination urls', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10712,7 +10714,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('loop over pagination rows', async (assert) => {
+ test('loop over pagination rows', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10727,7 +10729,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('use custom strategy for pagination keys', async (assert) => {
+ test('use custom strategy for pagination keys', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10778,7 +10780,7 @@ test.group('Query Builder | paginate', (group) => {
await connection.disconnect()
})
- test('use table aliases', async (assert) => {
+ test('use table aliases', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10820,22 +10822,22 @@ test.group('Query Builder | paginate', (group) => {
})
test.group('Query Builder | clone', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('clone query builder', async (assert) => {
+ test('clone query builder', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10846,7 +10848,7 @@ test.group('Query Builder | clone', (group) => {
await connection.disconnect()
})
- test('clone query builder with where clauses', async (assert) => {
+ test('clone query builder with where clauses', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10865,7 +10867,7 @@ test.group('Query Builder | clone', (group) => {
await connection.disconnect()
})
- test('deep clone where clauses', async (assert) => {
+ test('deep clone where clauses', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10895,7 +10897,7 @@ test.group('Query Builder | clone', (group) => {
await connection.disconnect()
})
- test('copy internals to the cloned query builder', async (assert) => {
+ test('copy internals to the cloned query builder', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -10908,22 +10910,22 @@ test.group('Query Builder | clone', (group) => {
})
test.group('Query Builder | event', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('emit db:query event when debug globally enabled', async (assert, done) => {
+ test('emit db:query event when debug globally enabled', async ({ assert }, done) => {
assert.plan(4)
const config = Object.assign({}, getConfig(), { debug: true })
@@ -10943,7 +10945,7 @@ test.group('Query Builder | event', (group) => {
await db.select('*').from('users')
await connection.disconnect()
- })
+ }).waitForDone()
test('do not emit db:query event when debug not enabled', async () => {
const config = Object.assign({}, getConfig(), { debug: false })
@@ -10961,7 +10963,7 @@ test.group('Query Builder | event', (group) => {
await connection.disconnect()
})
- test('emit db:query event when enabled on a single query', async (assert, done) => {
+ test('emit db:query event when enabled on a single query', async ({ assert }, done) => {
const config = Object.assign({}, getConfig(), { debug: false })
const emitter = app.container.use('Adonis/Core/Event')
@@ -10979,26 +10981,26 @@ test.group('Query Builder | event', (group) => {
await db.select('*').from('users').debug(true)
await connection.disconnect()
- })
+ }).waitForDone()
})
test.group('Query Builder | update', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('update columns by defining object', async (assert) => {
+ test('update columns by defining object', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11032,7 +11034,7 @@ test.group('Query Builder | update', (group) => {
await connection.disconnect()
})
- test('update columns by defining key-value pair', async (assert) => {
+ test('update columns by defining key-value pair', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11066,7 +11068,7 @@ test.group('Query Builder | update', (group) => {
await connection.disconnect()
})
- test('handle use case where update value is false or 0', async (assert) => {
+ test('handle use case where update value is false or 0', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11102,22 +11104,22 @@ test.group('Query Builder | update', (group) => {
})
test.group('Query Builder | whereColumn', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add where clause on another column', async (assert) => {
+ test('add where clause on another column', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11155,7 +11157,7 @@ test.group('Query Builder | whereColumn', (group) => {
await connection.disconnect()
})
- test('add or where clause on another column', async (assert) => {
+ test('add or where clause on another column', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11197,7 +11199,7 @@ test.group('Query Builder | whereColumn', (group) => {
await connection.disconnect()
})
- test('add where not clause on another column', async (assert) => {
+ test('add where not clause on another column', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11235,7 +11237,7 @@ test.group('Query Builder | whereColumn', (group) => {
await connection.disconnect()
})
- test('add or where not clause on another column', async (assert) => {
+ test('add or where not clause on another column', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11279,22 +11281,22 @@ test.group('Query Builder | whereColumn', (group) => {
})
test.group('Query Builder | conditionals', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('add constraints to query using if condition', async (assert) => {
+ test('add constraints to query using if condition', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11319,7 +11321,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('define else block for the if condition', async (assert) => {
+ test('define else block for the if condition', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11347,7 +11349,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('add constraints to query using unless condition', async (assert) => {
+ test('add constraints to query using unless condition', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11372,7 +11374,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('define else block for the unless condition', async (assert) => {
+ test('define else block for the unless condition', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11400,7 +11402,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('invoke conditional function to find the conditional value', async (assert) => {
+ test('invoke conditional function to find the conditional value', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11431,7 +11433,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('define a match block with no else statement', async (assert) => {
+ test('define a match block with no else statement', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11454,7 +11456,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('define match conditionals as functions', async (assert) => {
+ test('define match conditionals as functions', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11477,7 +11479,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('use the first matching block', async (assert) => {
+ test('use the first matching block', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11500,7 +11502,7 @@ test.group('Query Builder | conditionals', (group) => {
await connection.disconnect()
})
- test('use the else block when nothing matches', async (assert) => {
+ test('use the else block when nothing matches', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11526,22 +11528,22 @@ test.group('Query Builder | conditionals', (group) => {
})
test.group('Query Builder | wrapExisting', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('apply where clauses only once, when calling toSQL multiple times', async (assert) => {
+ test('apply where clauses only once, when calling toSQL multiple times', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11556,7 +11558,7 @@ test.group('Query Builder | wrapExisting', (group) => {
await connection.disconnect()
})
- test('allow mutating query where clauses post toSQL call', async (assert) => {
+ test('allow mutating query where clauses post toSQL call', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11572,22 +11574,22 @@ test.group('Query Builder | wrapExisting', (group) => {
})
test.group('Query Builder | with', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define with clause as a raw query', async (assert) => {
+ test('define with clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11610,7 +11612,7 @@ test.group('Query Builder | with', (group) => {
await connection.disconnect()
})
- test('define with clause as a callback', async (assert) => {
+ test('define with clause as a callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11633,7 +11635,7 @@ test.group('Query Builder | with', (group) => {
await connection.disconnect()
})
- test('define with clause as a subquery', async (assert) => {
+ test('define with clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11658,22 +11660,22 @@ test.group('Query Builder | with', (group) => {
})
test.group('Query Builder | withRecursive', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
app.container.use('Adonis/Core/Event').clearListeners('db:query')
await resetTables()
})
- test('define with clause as a raw query', async (assert) => {
+ test('define with clause as a raw query', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11696,7 +11698,7 @@ test.group('Query Builder | withRecursive', (group) => {
await connection.disconnect()
})
- test('define with clause as a callback', async (assert) => {
+ test('define with clause as a callback', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -11719,7 +11721,7 @@ test.group('Query Builder | withRecursive', (group) => {
await connection.disconnect()
})
- test('define with clause as a subquery', async (assert) => {
+ test('define with clause as a subquery', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
diff --git a/test/database/query-client.spec.ts b/test/database/query-client.spec.ts
index 8a8f58af..2e8bfa04 100644
--- a/test/database/query-client.spec.ts
+++ b/test/database/query-client.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { resolveClientNameWithAliases } from 'knex/lib/util/helpers'
@@ -20,21 +20,21 @@ import { fs, getConfig, setup, cleanup, resetTables, setupApplication } from '..
let app: ApplicationContract
test.group('Query client', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get query client in dual mode', async (assert) => {
+ test('get query client in dual mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -43,7 +43,7 @@ test.group('Query client', (group) => {
await connection.disconnect()
})
- test('get query client in read only mode', async (assert) => {
+ test('get query client in read only mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -52,7 +52,7 @@ test.group('Query client', (group) => {
await connection.disconnect()
})
- test('get query client in write only mode', async (assert) => {
+ test('get query client in write only mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -64,7 +64,7 @@ test.group('Query client', (group) => {
/**
* We cannot rely on knexjs for this and have to write our own code
*/
- test.skip('get query client dialect version', async (assert) => {
+ test('get query client dialect version', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -75,9 +75,9 @@ test.group('Query client', (group) => {
assert.exists(client1.dialect.version)
await connection.disconnect()
- })
+ }).skip(true)
- test('get columns info', async (assert) => {
+ test('get columns info', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -91,15 +91,19 @@ test.group('Query client', (group) => {
assert.property(columns, 'joined_at')
assert.property(columns, 'created_at')
assert.property(columns, 'updated_at')
+
+ await connection.disconnect()
})
- test('get single column info', async (assert) => {
+ test('get single column info', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('write', connection, app.container.use('Adonis/Core/Event'))
const column = await client.columnsInfo('users', 'id')
assert.oneOf(column.type, ['integer', 'int'])
+
+ await connection.disconnect()
})
if (process.env.DB !== 'mssql') {
@@ -136,26 +140,28 @@ test.group('Query client', (group) => {
*/
await connection.client?.schema.dropTable('test_profiles')
await connection.client?.schema.dropTable('test_users')
+
+ await connection.disconnect()
})
}
})
test.group('Query client | dual mode', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('perform select queries in dual mode', async (assert) => {
+ test('perform select queries in dual mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('dual', connection, app.container.use('Adonis/Core/Event'))
@@ -167,7 +173,7 @@ test.group('Query client | dual mode', (group) => {
await connection.disconnect()
})
- test('perform insert queries in dual mode', async (assert) => {
+ test('perform insert queries in dual mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('dual', connection, app.container.use('Adonis/Core/Event'))
@@ -182,7 +188,7 @@ test.group('Query client | dual mode', (group) => {
await connection.disconnect()
})
- test('perform raw queries in dual mode', async (assert) => {
+ test('perform raw queries in dual mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('dual', connection, app.container.use('Adonis/Core/Event'))
@@ -204,7 +210,7 @@ test.group('Query client | dual mode', (group) => {
await connection.disconnect()
})
- test('perform queries inside a transaction in dual mode', async (assert) => {
+ test('perform queries inside a transaction in dual mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('dual', connection, app.container.use('Adonis/Core/Event'))
@@ -223,21 +229,21 @@ test.group('Query client | dual mode', (group) => {
})
test.group('Query client | read mode', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('perform select queries in read mode', async (assert) => {
+ test('perform select queries in read mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('read', connection, app.container.use('Adonis/Core/Event'))
@@ -249,18 +255,18 @@ test.group('Query client | read mode', (group) => {
await connection.disconnect()
})
- test('raise error when attempting to perform insert in read mode', async (assert) => {
+ test('raise error when attempting to perform insert in read mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('read', connection, app.container.use('Adonis/Core/Event'))
const fn = () => client.insertQuery()
- assert.throw(fn, 'Write client is not available for query client instantiated in read mode')
+ assert.throws(fn, 'Write client is not available for query client instantiated in read mode')
await connection.disconnect()
})
- test('perform raw queries in read mode', async (assert) => {
+ test('perform raw queries in read mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('read', connection, app.container.use('Adonis/Core/Event'))
@@ -271,7 +277,7 @@ test.group('Query client | read mode', (group) => {
await connection.disconnect()
})
- test('raise error when attempting to get transaction in read mode', async (assert) => {
+ test('raise error when attempting to get transaction in read mode', async ({ assert }) => {
assert.plan(1)
const connection = new Connection('primary', getConfig(), app.logger)
@@ -292,21 +298,21 @@ test.group('Query client | read mode', (group) => {
})
test.group('Query client | write mode', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('perform select queries in write mode', async (assert) => {
+ test('perform select queries in write mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('write', connection, app.container.use('Adonis/Core/Event'))
@@ -318,7 +324,7 @@ test.group('Query client | write mode', (group) => {
await connection.disconnect()
})
- test('perform insert queries in write mode', async (assert) => {
+ test('perform insert queries in write mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('write', connection, app.container.use('Adonis/Core/Event'))
@@ -333,7 +339,7 @@ test.group('Query client | write mode', (group) => {
await connection.disconnect()
})
- test('perform raw queries in write mode', async (assert) => {
+ test('perform raw queries in write mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('write', connection, app.container.use('Adonis/Core/Event'))
@@ -355,7 +361,7 @@ test.group('Query client | write mode', (group) => {
await connection.disconnect()
})
- test('perform queries inside a transaction in write mode', async (assert) => {
+ test('perform queries inside a transaction in write mode', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
const client = new QueryClient('write', connection, app.container.use('Adonis/Core/Event'))
@@ -375,21 +381,21 @@ test.group('Query client | write mode', (group) => {
if (!['sqlite', 'mssql', 'better_sqlite'].includes(process.env.DB as string)) {
test.group('Query client | advisory locks', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get advisory lock', async (assert) => {
+ test('get advisory lock', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -403,7 +409,7 @@ if (!['sqlite', 'mssql', 'better_sqlite'].includes(process.env.DB as string)) {
await connection.disconnect()
})
- test('release advisory lock', async (assert) => {
+ test('release advisory lock', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -423,21 +429,21 @@ if (!['sqlite', 'mssql', 'better_sqlite'].includes(process.env.DB as string)) {
}
test.group('Query client | get tables', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get an array of tables', async (assert) => {
+ test('get an array of tables', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -476,5 +482,7 @@ test.group('Query client | get tables', (group) => {
'uuid_users',
])
}
+
+ await connection.disconnect()
})
})
diff --git a/test/database/transactions.spec.ts b/test/database/transactions.spec.ts
index 1978a5fa..9a1f4c96 100644
--- a/test/database/transactions.spec.ts
+++ b/test/database/transactions.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { Connection } from '../../src/Connection'
@@ -20,21 +20,21 @@ import { fs, setup, cleanup, getConfig, resetTables, setupApplication } from '..
let app: ApplicationContract
test.group('Transaction | query', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('perform select query under a transaction', async (assert) => {
+ test('perform select query under a transaction', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -52,7 +52,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('commit insert', async (assert) => {
+ test('commit insert', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -78,7 +78,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('rollback insert', async (assert) => {
+ test('rollback insert', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -103,7 +103,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('perform nested transactions with save points', async (assert) => {
+ test('perform nested transactions with save points', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -147,7 +147,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('emit after commit event', async (assert) => {
+ test('emit after commit event', async ({ assert }) => {
const stack: string[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -173,7 +173,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('emit after rollback event', async (assert) => {
+ test('emit after rollback event', async ({ assert }) => {
const stack: string[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -198,7 +198,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('commit insert inside a self managed transaction', async (assert) => {
+ test('commit insert inside a self managed transaction', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -222,7 +222,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('rollback insert inside a self managed transaction', async (assert) => {
+ test('rollback insert inside a self managed transaction', async ({ assert }) => {
assert.plan(3)
const connection = new Connection('primary', getConfig(), app.logger)
@@ -252,7 +252,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('perform nested managed transactions', async (assert) => {
+ test('perform nested managed transactions', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -291,7 +291,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('nest transaction queries inside profiler row', async (assert) => {
+ test('nest transaction queries inside profiler row', async ({ assert }) => {
const stack: { id: string; parentId: string | undefined; label: string; data: any }[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -317,7 +317,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('nest save points queries inside profiler row', async (assert) => {
+ test('nest save points queries inside profiler row', async ({ assert }) => {
const stack: { id: string; parentId: string | undefined; label: string; data: any }[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -348,7 +348,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('nest transaction queries inside managed transaction', async (assert) => {
+ test('nest transaction queries inside managed transaction', async ({ assert }) => {
const stack: { id: string; parentId: string | undefined; label: string; data: any }[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -374,7 +374,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('execute after commit hook', async (assert) => {
+ test('execute after commit hook', async ({ assert }) => {
const stack: string[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -396,7 +396,7 @@ test.group('Transaction | query', (group) => {
await connection.disconnect()
})
- test('execute after rollback hook', async (assert) => {
+ test('execute after rollback hook', async ({ assert }) => {
const stack: string[] = []
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
diff --git a/test/database/views-types.spec.ts b/test/database/views-types.spec.ts
index 6bbb6303..39d7a448 100644
--- a/test/database/views-types.spec.ts
+++ b/test/database/views-types.spec.ts
@@ -1,6 +1,6 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { join } from 'path'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -11,19 +11,19 @@ import { fs, getConfig, setup, cleanup, setupApplication } from '../../test-help
let app: ApplicationContract
test.group('Query client | Views and types', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup(['temp_posts', 'temp_users'])
await cleanup()
await fs.cleanup()
})
if (['sqlite', 'mysql', 'pg'].includes(process.env.DB!)) {
- test('Get all views', async (assert) => {
+ test('Get all views', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'temp'))
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -43,9 +43,10 @@ test.group('Query client | Views and types', (group) => {
assert.deepEqual(allViews.sort(), ['users_view', 'follows_view'].sort())
await client.dropAllViews()
+ await connection.disconnect()
})
- test('Drop all views', async (assert) => {
+ test('Drop all views', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'temp'))
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -68,11 +69,13 @@ test.group('Query client | Views and types', (group) => {
allViews = await client.getAllViews(['public'])
assert.equal(allViews.length, 0)
+
+ await connection.disconnect()
})
}
if (['pg'].includes(process.env.DB!)) {
- test('Get all types', async (assert) => {
+ test('Get all types', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'temp'))
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -85,9 +88,10 @@ test.group('Query client | Views and types', (group) => {
assert.equal(types[0], 'user_type')
await client.dropAllTypes()
+ await connection.disconnect()
})
- test('Drop all types', async (assert) => {
+ test('Drop all types', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'temp'))
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()
@@ -98,6 +102,7 @@ test.group('Query client | Views and types', (group) => {
const types = await client.getAllTypes()
assert.equal(types.length, 0)
+ await connection.disconnect()
})
}
})
diff --git a/test/factory/belongs-to-spec.ts b/test/factory/belongs-to-spec.ts
index 50482a93..a0cb7d09 100644
--- a/test/factory/belongs-to-spec.ts
+++ b/test/factory/belongs-to-spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { BelongsTo } from '@ioc:Adonis/Lucid/Orm'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -35,24 +35,24 @@ const FactoryModel = getFactoryModel()
const factoryManager = new FactoryManager()
test.group('Factory | BelongTo | make', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('make model with relationship', async (assert) => {
+ test('make model with relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public id: number
@@ -109,7 +109,7 @@ test.group('Factory | BelongTo | make', (group) => {
assert.equal(profile.user.id, profile.userId)
})
- test('pass custom attributes to the relationship', async (assert) => {
+ test('pass custom attributes to the relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public id: number
@@ -172,7 +172,7 @@ test.group('Factory | BelongTo | make', (group) => {
assert.equal(profile.user.points, 10)
})
- test('invoke make hook on the related factory', async (assert) => {
+ test('invoke make hook on the related factory', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public id: number
@@ -243,24 +243,24 @@ test.group('Factory | BelongTo | make', (group) => {
})
test.group('Factory | BelongTo | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create model with relationship', async (assert) => {
+ test('create model with relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -319,7 +319,7 @@ test.group('Factory | BelongTo | create', (group) => {
assert.equal(profiles[0].user_id, users[0].id)
})
- test('pass custom attributes to the relationship', async (assert) => {
+ test('pass custom attributes to the relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -376,7 +376,7 @@ test.group('Factory | BelongTo | create', (group) => {
assert.equal(profile.user.points, 10)
})
- test('create model with custom foreign key', async (assert) => {
+ test('create model with custom foreign key', async ({ assert }) => {
class Profile extends BaseModel {
@column({ columnName: 'user_id' })
public authorId: number
@@ -433,7 +433,7 @@ test.group('Factory | BelongTo | create', (group) => {
assert.equal(profile.user.points, 10)
})
- test('rollback changes on error', async (assert) => {
+ test('rollback changes on error', async ({ assert }) => {
assert.plan(3)
class Profile extends BaseModel {
diff --git a/test/factory/factory-builder.spec.ts b/test/factory/factory-builder.spec.ts
index 1448b79c..0bf7a0fd 100644
--- a/test/factory/factory-builder.spec.ts
+++ b/test/factory/factory-builder.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { randomUUID } from 'crypto'
import { column } from '../../src/Orm/Decorators'
import { FactoryManager } from '../../src/Factory/index'
@@ -36,24 +36,24 @@ const FactoryModel = getFactoryModel()
const factoryManager = new FactoryManager()
test.group('Factory | Factory Builder | make', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply factory model state', async (assert) => {
+ test('apply factory model state', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -81,7 +81,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('applying a state twice must be a noop', async (assert) => {
+ test('applying a state twice must be a noop', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -112,7 +112,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('merge custom attributes', async (assert) => {
+ test('merge custom attributes', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -140,7 +140,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('define custom merge function', async (assert) => {
+ test('define custom merge function', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -170,7 +170,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('define custom newUp function', async (assert) => {
+ test('define custom newUp function', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -207,7 +207,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('use 0 index elements when attributes are defined as an array', async (assert) => {
+ test('use 0 index elements when attributes are defined as an array', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -235,7 +235,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('invoke after make hook', async (assert) => {
+ test('invoke after make hook', async ({ assert }) => {
assert.plan(6)
class User extends BaseModel {
@@ -271,7 +271,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('invoke after makeStubbed hook', async (assert) => {
+ test('invoke after makeStubbed hook', async ({ assert }) => {
assert.plan(6)
class User extends BaseModel {
@@ -307,7 +307,7 @@ test.group('Factory | Factory Builder | make', (group) => {
assert.isFalse(user.$isPersisted)
})
- test('define custom id inside make hook', async (assert) => {
+ test('define custom id inside make hook', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -345,24 +345,24 @@ test.group('Factory | Factory Builder | make', (group) => {
})
test.group('Factory | Factory Builder | makeMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply factory model state', async (assert) => {
+ test('apply factory model state', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -395,7 +395,7 @@ test.group('Factory | Factory Builder | makeMany', (group) => {
assert.isFalse(users[1].$isPersisted)
})
- test('applying a state twice must be a noop', async (assert) => {
+ test('applying a state twice must be a noop', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -429,7 +429,7 @@ test.group('Factory | Factory Builder | makeMany', (group) => {
assert.isFalse(users[1].$isPersisted)
})
- test('define custom attributes accepted by the newUp method', async (assert) => {
+ test('define custom attributes accepted by the newUp method', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -463,7 +463,7 @@ test.group('Factory | Factory Builder | makeMany', (group) => {
assert.isFalse(users[1].$isPersisted)
})
- test('define index specific attributes for makeMany', async (assert) => {
+ test('define index specific attributes for makeMany', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -499,7 +499,7 @@ test.group('Factory | Factory Builder | makeMany', (group) => {
assert.isFalse(users[1].$isPersisted)
})
- test('run makeStubbed hook for all the model instances', async (assert) => {
+ test('run makeStubbed hook for all the model instances', async ({ assert }) => {
assert.plan(15)
class User extends BaseModel {
@@ -540,7 +540,7 @@ test.group('Factory | Factory Builder | makeMany', (group) => {
assert.isFalse(users[1].$isPersisted)
})
- test('run make hook for all the model instances', async (assert) => {
+ test('run make hook for all the model instances', async ({ assert }) => {
assert.plan(15)
class User extends BaseModel {
@@ -583,24 +583,24 @@ test.group('Factory | Factory Builder | makeMany', (group) => {
})
test.group('Factory | Factory Builder | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply factory model state', async (assert) => {
+ test('apply factory model state', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -627,7 +627,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('applying a state twice must be a noop', async (assert) => {
+ test('applying a state twice must be a noop', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -654,7 +654,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('define custom attributes accepted by the newUp method', async (assert) => {
+ test('define custom attributes accepted by the newUp method', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -681,7 +681,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('use index 0 elements when attributes are defined as an array', async (assert) => {
+ test('use index 0 elements when attributes are defined as an array', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -708,7 +708,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('invoke before and after create hook', async (assert) => {
+ test('invoke before and after create hook', async ({ assert }) => {
assert.plan(4)
class User extends BaseModel {
@@ -743,7 +743,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('invoke after make hook', async (assert) => {
+ test('invoke after make hook', async ({ assert }) => {
assert.plan(6)
const stack: string[] = []
@@ -786,7 +786,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.deepEqual(stack, ['afterMake', 'beforeCreate', 'afterCreate'])
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -821,7 +821,7 @@ test.group('Factory | Factory Builder | create', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('define custom query client', async (assert) => {
+ test('define custom query client', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -860,24 +860,24 @@ test.group('Factory | Factory Builder | create', (group) => {
})
test.group('Factory | Factory Builder | createMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply factory model state', async (assert) => {
+ test('apply factory model state', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -907,7 +907,7 @@ test.group('Factory | Factory Builder | createMany', (group) => {
assert.isTrue(users[1].$isPersisted)
})
- test('applying a state twice must be a noop', async (assert) => {
+ test('applying a state twice must be a noop', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -937,7 +937,7 @@ test.group('Factory | Factory Builder | createMany', (group) => {
assert.isTrue(users[1].$isPersisted)
})
- test('define custom attributes accepted by the newUp method', async (assert) => {
+ test('define custom attributes accepted by the newUp method', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -968,7 +968,7 @@ test.group('Factory | Factory Builder | createMany', (group) => {
assert.isTrue(users[1].$isPersisted)
})
- test('define index specific attributes for makeMany', async (assert) => {
+ test('define index specific attributes for makeMany', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/factory/factory-model.spec.ts b/test/factory/factory-model.spec.ts
index 50ade516..b2040725 100644
--- a/test/factory/factory-model.spec.ts
+++ b/test/factory/factory-model.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasOne } from '@ioc:Adonis/Lucid/Orm'
import { column, hasOne } from '../../src/Orm/Decorators'
@@ -35,24 +35,24 @@ let BaseModel: ReturnType
const factoryManager = new FactoryManager()
test.group('Factory | Factory Model', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define model factory', async (assert) => {
+ test('define model factory', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -65,7 +65,7 @@ test.group('Factory | Factory Model', (group) => {
assert.instanceOf(factory, FactoryModel)
})
- test('define factory state', async (assert) => {
+ test('define factory state', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -82,7 +82,7 @@ test.group('Factory | Factory Model', (group) => {
assert.deepEqual(factory.states, { active: stateFn })
})
- test('define factory relation', async (assert) => {
+ test('define factory relation', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -110,7 +110,7 @@ test.group('Factory | Factory Model', (group) => {
assert.instanceOf(factory.relations.profile, FactoryHasOne)
})
- test('get pre-registered state', async (assert) => {
+ test('get pre-registered state', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -127,7 +127,7 @@ test.group('Factory | Factory Model', (group) => {
assert.deepEqual(factory.getState('active'), stateFn)
})
- test('raise exception when state is not registered', async (assert) => {
+ test('raise exception when state is not registered', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -137,13 +137,13 @@ test.group('Factory | Factory Model', (group) => {
}
const factory = new FactoryModel(User, () => new User(), factoryManager)
- assert.throw(
+ assert.throws(
() => factory.getState('active'),
'Cannot apply undefined state "active". Double check the model factory'
)
})
- test('get pre-registered relationship', async (assert) => {
+ test('get pre-registered relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -175,7 +175,7 @@ test.group('Factory | Factory Model', (group) => {
assert.deepEqual(factory.getRelation('profile').relation, User.$getRelation('profile')!)
})
- test('raise exception when relation is not defined', async (assert) => {
+ test('raise exception when relation is not defined', async ({ assert }) => {
class Profile extends BaseModel {}
Profile.boot()
@@ -191,13 +191,13 @@ test.group('Factory | Factory Model', (group) => {
}
const factory = new FactoryModel(User, () => new User(), factoryManager)
- assert.throw(
+ assert.throws(
() => factory.getRelation('profile'),
'Cannot setup undefined relationship "profile". Double check the model factory'
)
})
- test('do not allow registering relationships not defined on the model', async (assert) => {
+ test('do not allow registering relationships not defined on the model', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -208,13 +208,13 @@ test.group('Factory | Factory Model', (group) => {
const factory = () =>
new FactoryModel(User, () => new User(), factoryManager).relation('profile' as any, () => {})
- assert.throw(
+ assert.throws(
factory,
'Cannot define "profile" relationship. The relationship must exist on the "User" model first'
)
})
- test('build factory', async (assert) => {
+ test('build factory', async ({ assert }) => {
class Profile extends BaseModel {}
Profile.boot()
@@ -241,7 +241,7 @@ test.group('Factory | Factory Model', (group) => {
assert.instanceOf(user, User)
})
- test('return model instance from the factory callback', async (assert) => {
+ test('return model instance from the factory callback', async ({ assert }) => {
class Profile extends BaseModel {}
Profile.boot()
diff --git a/test/factory/has-many.spec.ts b/test/factory/has-many.spec.ts
index 8c340a01..25df22b0 100644
--- a/test/factory/has-many.spec.ts
+++ b/test/factory/has-many.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasMany } from '@ioc:Adonis/Lucid/Orm'
import { FactoryManager } from '../../src/Factory/index'
import { column, hasMany } from '../../src/Orm/Decorators'
@@ -34,24 +34,24 @@ const FactoryModel = getFactoryModel()
const factoryManager = new FactoryManager()
test.group('Factory | HasMany | make', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('make model with relationship', async (assert) => {
+ test('make model with relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public id: number
@@ -110,7 +110,7 @@ test.group('Factory | HasMany | make', (group) => {
assert.equal(user.posts[0].userId, user.id)
})
- test('pass custom attributes to relationship', async (assert) => {
+ test('pass custom attributes to relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -166,7 +166,7 @@ test.group('Factory | HasMany | make', (group) => {
assert.equal(user.posts[0].title, 'Lucid 101')
})
- test('make many relationship', async (assert) => {
+ test('make many relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -227,24 +227,24 @@ test.group('Factory | HasMany | make', (group) => {
})
test.group('Factory | HasMany | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create model with relationship', async (assert) => {
+ test('create model with relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -304,7 +304,7 @@ test.group('Factory | HasMany | create', (group) => {
assert.equal(posts[0].user_id, users[0].id)
})
- test('pass custom attributes to relationship', async (assert) => {
+ test('pass custom attributes to relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -360,7 +360,7 @@ test.group('Factory | HasMany | create', (group) => {
assert.equal(user.posts[0].title, 'Lucid 101')
})
- test('create many relationship', async (assert) => {
+ test('create many relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -420,7 +420,7 @@ test.group('Factory | HasMany | create', (group) => {
assert.equal(user.posts[1].title, 'Lucid 101')
})
- test('create relationship with custom foreign key', async (assert) => {
+ test('create relationship with custom foreign key', async ({ assert }) => {
class Post extends BaseModel {
@column({ columnName: 'user_id' })
public authorId: number
@@ -476,7 +476,7 @@ test.group('Factory | HasMany | create', (group) => {
assert.equal(user.posts[0].title, 'Lucid 101')
})
- test('rollback changes on error', async (assert) => {
+ test('rollback changes on error', async ({ assert }) => {
assert.plan(3)
class Post extends BaseModel {
diff --git a/test/factory/has-one.spec.ts b/test/factory/has-one.spec.ts
index bef5c4cf..ff5074da 100644
--- a/test/factory/has-one.spec.ts
+++ b/test/factory/has-one.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasOne } from '@ioc:Adonis/Lucid/Orm'
import { FactoryManager } from '../../src/Factory/index'
import { column, hasOne } from '../../src/Orm/Decorators'
@@ -34,24 +34,24 @@ const FactoryModel = getFactoryModel()
const factoryManager = new FactoryManager()
test.group('Factory | HasOne | make', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('make model with relationship', async (assert) => {
+ test('make model with relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public id: number
@@ -109,7 +109,7 @@ test.group('Factory | HasOne | make', (group) => {
assert.equal(user.profile.userId, user.id)
})
- test('pass custom attributes to relationship', async (assert) => {
+ test('pass custom attributes to relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public id: number
@@ -171,24 +171,24 @@ test.group('Factory | HasOne | make', (group) => {
})
test.group('Factory | HasOne | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create model with relationship', async (assert) => {
+ test('create model with relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -247,7 +247,7 @@ test.group('Factory | HasOne | create', (group) => {
assert.equal(profiles[0].user_id, users[0].id)
})
- test('pass custom attributes to relationship', async (assert) => {
+ test('pass custom attributes to relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -302,7 +302,7 @@ test.group('Factory | HasOne | create', (group) => {
assert.equal(user.profile.userId, user.id)
})
- test('create model with custom foreign key', async (assert) => {
+ test('create model with custom foreign key', async ({ assert }) => {
class Profile extends BaseModel {
@column({ columnName: 'user_id' })
public authorId: number
@@ -354,7 +354,7 @@ test.group('Factory | HasOne | create', (group) => {
assert.equal(user.profile.authorId, user.id)
})
- test('rollback changes on error', async (assert) => {
+ test('rollback changes on error', async ({ assert }) => {
assert.plan(3)
class Profile extends BaseModel {
diff --git a/test/factory/many-to-many.spec.ts b/test/factory/many-to-many.spec.ts
index 858d5004..699910d2 100644
--- a/test/factory/many-to-many.spec.ts
+++ b/test/factory/many-to-many.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { ManyToMany } from '@ioc:Adonis/Lucid/Orm'
import { FactoryManager } from '../../src/Factory/index'
import { column, manyToMany } from '../../src/Orm/Decorators'
@@ -34,24 +34,24 @@ const FactoryModel = getFactoryModel()
const factoryManager = new FactoryManager()
test.group('Factory | ManyToMany | make', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('make model with relationship', async (assert) => {
+ test('make model with relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -107,7 +107,7 @@ test.group('Factory | ManyToMany | make', (group) => {
assert.isFalse(user.skills[0].$isPersisted)
})
- test('pass custom attributes to relationship', async (assert) => {
+ test('pass custom attributes to relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -164,7 +164,7 @@ test.group('Factory | ManyToMany | make', (group) => {
assert.equal(user.skills[0].name, 'Dancing')
})
- test('make many relationship', async (assert) => {
+ test('make many relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -228,24 +228,24 @@ test.group('Factory | ManyToMany | make', (group) => {
})
test.group('Factory | ManyToMany | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create model with relationship', async (assert) => {
+ test('create model with relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -306,7 +306,7 @@ test.group('Factory | ManyToMany | create', (group) => {
assert.equal(skillUsers[0].skill_id, skills[0].id)
})
- test('pass custom attributes', async (assert) => {
+ test('pass custom attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -361,7 +361,7 @@ test.group('Factory | ManyToMany | create', (group) => {
assert.equal(user.skills[0].name, 'Dancing')
})
- test('create many relationships', async (assert) => {
+ test('create many relationships', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -420,7 +420,7 @@ test.group('Factory | ManyToMany | create', (group) => {
assert.equal(user.skills[1].name, 'Programming')
})
- test('rollback changes on error', async (assert) => {
+ test('rollback changes on error', async ({ assert }) => {
assert.plan(4)
class Skill extends BaseModel {
diff --git a/test/migrations/migration-source.spec.ts b/test/migrations/migration-source.spec.ts
index 1b94783c..7b447aa8 100644
--- a/test/migrations/migration-source.spec.ts
+++ b/test/migrations/migration-source.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { join } from 'path'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -20,19 +20,19 @@ let app: ApplicationContract
let db: ReturnType
test.group('MigrationSource', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await db.manager.closeAll()
await resetTables()
await fs.cleanup()
})
- test('get list of migration files from database/migrations.js', async (assert) => {
+ test('get list of migration files from database/migrations.js', async ({ assert }) => {
const migrationSource = new MigrationSource(db.getRawConnection('primary')!.config, app)
await fs.add('database/migrations/foo.js', 'module.exports = class Foo {}')
@@ -57,7 +57,7 @@ test.group('MigrationSource', (group) => {
)
})
- test('only use javascript files for migration', async (assert) => {
+ test('only use javascript files for migration', async ({ assert }) => {
const migrationSource = new MigrationSource(db.getRawConnection('primary')!.config, app)
await fs.add('database/migrations/foo.js', 'module.exports = class Foo {}')
@@ -78,7 +78,7 @@ test.group('MigrationSource', (group) => {
)
})
- test('sort multiple migration directories seperately', async (assert) => {
+ test('sort multiple migration directories seperately', async ({ assert }) => {
const config = Object.assign({}, db.getRawConnection('primary')!.config, {
migrations: {
paths: ['./database/secondary', './database/primary'],
@@ -120,7 +120,7 @@ test.group('MigrationSource', (group) => {
)
})
- test('handle esm default exports properly', async (assert) => {
+ test('handle esm default exports properly', async ({ assert }) => {
const migrationSource = new MigrationSource(db.getRawConnection('primary')!.config, app)
await fs.add('database/migrations/foo.ts', 'export default class Foo {}')
diff --git a/test/migrations/migrator.spec.ts b/test/migrations/migrator.spec.ts
index 3536c56e..43d91262 100644
--- a/test/migrations/migrator.spec.ts
+++ b/test/migrations/migrator.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { join, sep } from 'path'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -27,13 +27,13 @@ let db: ReturnType
let app: ApplicationContract
test.group('Migrator', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
await db.manager.closeAll()
await cleanup()
@@ -41,7 +41,7 @@ test.group('Migrator', (group) => {
await fs.cleanup()
})
- test('create the schema table when there are no migrations', async (assert) => {
+ test('create the schema table when there are no migrations', async ({ assert }) => {
await fs.fsExtra.ensureDir(join(fs.basePath, 'database/migrations'))
const migrator = getMigrator(db, app, {
@@ -56,7 +56,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.status, 'skipped')
})
- test('migrate database using schema files', async (assert) => {
+ test('migrate database using schema files', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -102,7 +102,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.status, 'completed')
})
- test('do not migrate when schema up action fails', async (assert) => {
+ test('do not migrate when schema up action fails', async ({ assert }) => {
assert.plan(8)
await fs.add(
@@ -174,7 +174,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.error!.message, 'table.badMethod is not a function')
})
- test('do not migrate when dryRun is true', async (assert) => {
+ test('do not migrate when dryRun is true', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -256,7 +256,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.status, 'completed')
})
- test('catch and report errors in dryRun', async (assert) => {
+ test('catch and report errors in dryRun', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -325,7 +325,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.status, 'error')
})
- test('do not migrate a schema file twice', async (assert) => {
+ test('do not migrate a schema file twice', async ({ assert }) => {
await fs.add(
'database/migrations/accounts.ts',
`
@@ -380,7 +380,7 @@ test.group('Migrator', (group) => {
assert.isTrue(hasUsersTable, 'Has users table')
})
- test('rollback database using schema files to a given batch', async (assert) => {
+ test('rollback database using schema files to a given batch', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -453,7 +453,7 @@ test.group('Migrator', (group) => {
])
})
- test('rollback database to the latest batch', async (assert) => {
+ test('rollback database to the latest batch', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -522,7 +522,7 @@ test.group('Migrator', (group) => {
])
})
- test('rollback all down to batch 0', async (assert) => {
+ test('rollback all down to batch 0', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -602,7 +602,7 @@ test.group('Migrator', (group) => {
])
})
- test('rollback multiple times must be a noop', async (assert) => {
+ test('rollback multiple times must be a noop', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -700,7 +700,7 @@ test.group('Migrator', (group) => {
assert.deepEqual(migrator3Files, [])
})
- test('do not rollback in dryRun', async (assert) => {
+ test('do not rollback in dryRun', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -781,7 +781,7 @@ test.group('Migrator', (group) => {
])
})
- test('do not rollback when a schema file goes missing', async (assert) => {
+ test('do not rollback when a schema file goes missing', async ({ assert }) => {
assert.plan(4)
await fs.add(
@@ -846,7 +846,7 @@ test.group('Migrator', (group) => {
)
})
- test('get list of migrated files', async (assert) => {
+ test('get list of migrated files', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -895,7 +895,7 @@ test.group('Migrator', (group) => {
assert.equal(files[1].batch, 1)
})
- test('skip upcoming migrations after failure', async (assert) => {
+ test('skip upcoming migrations after failure', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -966,7 +966,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.status, 'error')
})
- test('use a natural sort to order files when configured', async (assert) => {
+ test('use a natural sort to order files when configured', async ({ assert }) => {
const originalConfig = Object.assign({}, db.getRawConnection('primary')!.config)
db.getRawConnection('primary')!.config.migrations = {
@@ -1018,7 +1018,7 @@ test.group('Migrator', (group) => {
assert.equal(files[1].name, `database${sep}migrations${sep}12_users`)
})
- test('use a natural sort to order nested files when configured', async (assert) => {
+ test('use a natural sort to order nested files when configured', async ({ assert }) => {
const originalConfig = Object.assign({}, db.getRawConnection('primary')!.config)
db.getRawConnection('primary')!.config.migrations = {
@@ -1070,7 +1070,7 @@ test.group('Migrator', (group) => {
assert.equal(files[1].name, `database${sep}migrations${sep}12${sep}1_accounts`)
})
- test('raise exception when rollbacks in production are disabled', async (assert) => {
+ test('raise exception when rollbacks in production are disabled', async ({ assert }) => {
app.nodeEnvironment = 'production'
const originalConfig = Object.assign({}, db.getRawConnection('primary')!.config)
@@ -1140,7 +1140,7 @@ test.group('Migrator', (group) => {
delete process.env.NODE_ENV
})
- test('upgrade old migration file name to new', async (assert) => {
+ test('upgrade old migration file name to new', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
@@ -1198,7 +1198,7 @@ test.group('Migrator', (group) => {
assert.equal(migrator.status, 'skipped')
})
- test('upgrade file names also in dryRun', async (assert) => {
+ test('upgrade file names also in dryRun', async ({ assert }) => {
await fs.add(
'database/migrations/users.ts',
`
diff --git a/test/migrations/schema.spec.ts b/test/migrations/schema.spec.ts
index f15e2c33..ba843b5b 100644
--- a/test/migrations/schema.spec.ts
+++ b/test/migrations/schema.spec.ts
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
-import test from 'japa'
+import { test } from '@japa/runner'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { setup, cleanup, getDb, getBaseSchema, setupApplication, fs } from '../../test-helpers'
@@ -15,19 +15,19 @@ let db: ReturnType
let app: ApplicationContract
test.group('Schema', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('get schema queries defined inside the up method in dry run', async (assert) => {
+ test('get schema queries defined inside the up method in dry run', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public up() {
this.schema.createTable('users', (table) => {
@@ -51,7 +51,7 @@ test.group('Schema', (group) => {
assert.deepEqual(queries, [knexSchema])
})
- test('get schema queries defined inside the down method in dry run', async (assert) => {
+ test('get schema queries defined inside the down method in dry run', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public down() {
this.schema.dropTable('users')
@@ -65,7 +65,7 @@ test.group('Schema', (group) => {
assert.deepEqual(queries, [knexSchema])
})
- test('get knex raw query builder using now method', async (assert) => {
+ test('get knex raw query builder using now method', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public up() {
this.schema.createTable('users', (table) => {
@@ -79,7 +79,7 @@ test.group('Schema', (group) => {
assert.equal(schema.now().toQuery(), 'CURRENT_TIMESTAMP')
})
- test('do not execute defer calls in dry run', async (assert) => {
+ test('do not execute defer calls in dry run', async ({ assert }) => {
assert.plan(1)
class UsersSchema extends getBaseSchema() {
@@ -95,7 +95,7 @@ test.group('Schema', (group) => {
await schema.execUp()
})
- test('execute up method queries on a given connection', async (assert) => {
+ test('execute up method queries on a given connection', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public up() {
this.schema.createTable('schema_users', (table) => {
@@ -130,7 +130,7 @@ test.group('Schema', (group) => {
assert.isTrue(hasAccounts)
})
- test('execute up method deferred actions in correct sequence', async (assert) => {
+ test('execute up method deferred actions in correct sequence', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public up() {
this.schema.createTable('schema_users', (table) => {
@@ -166,7 +166,7 @@ test.group('Schema', (group) => {
await db.connection().schema.dropTable('schema_users')
})
- test('execute down method queries on a given connection', async (assert) => {
+ test('execute down method queries on a given connection', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public up() {
this.schema.createTable('schema_users', (table) => {
@@ -212,7 +212,7 @@ test.group('Schema', (group) => {
assert.isFalse(hasAccounts)
})
- test('use now helper to define default timestamp', async (assert) => {
+ test('use now helper to define default timestamp', async ({ assert }) => {
class UsersSchema extends getBaseSchema() {
public up() {
this.schema.createTable('users', (table) => {
@@ -236,7 +236,7 @@ test.group('Schema', (group) => {
assert.deepEqual(queries, [knexSchema])
})
- test('emit db:query event when schema instructions are executed', async (assert) => {
+ test('emit db:query event when schema instructions are executed', async ({ assert }) => {
assert.plan(10)
class UsersSchema extends getBaseSchema() {
@@ -310,7 +310,7 @@ test.group('Schema', (group) => {
await db.connection().schema.dropTable('schema_users')
})
- test('emit db:query when enabled on the schema', async (assert) => {
+ test('emit db:query when enabled on the schema', async ({ assert }) => {
assert.plan(10)
class UsersSchema extends getBaseSchema() {
diff --git a/test/orm/adapter.spec.ts b/test/orm/adapter.spec.ts
index f7bea9f7..3347db3f 100644
--- a/test/orm/adapter.spec.ts
+++ b/test/orm/adapter.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { column } from '../../src/Orm/Decorators'
@@ -29,20 +29,20 @@ let BaseModel: ReturnType
let app: ApplicationContract
test.group('Adapter', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('make insert call using a model', async (assert) => {
+ test('make insert call using a model', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -65,7 +65,7 @@ test.group('Adapter', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('make update call using a model', async (assert) => {
+ test('make update call using a model', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -93,7 +93,7 @@ test.group('Adapter', (group) => {
await user.save()
})
- test('make delete call using a model', async (assert) => {
+ test('make delete call using a model', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -121,7 +121,7 @@ test.group('Adapter', (group) => {
assert.lengthOf(users, 0)
})
- test('get array of model instances using the all call', async (assert) => {
+ test('get array of model instances using the all call', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -151,7 +151,7 @@ test.group('Adapter', (group) => {
assert.deepEqual(users[1].$attributes, { id: 1, username: 'virk' })
})
- test('use transaction client set on the model for the insert', async (assert) => {
+ test('use transaction client set on the model for the insert', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -181,7 +181,7 @@ test.group('Adapter', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('do not insert when transaction rollbacks', async (assert) => {
+ test('do not insert when transaction rollbacks', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -211,7 +211,7 @@ test.group('Adapter', (group) => {
assert.isTrue(user.$isPersisted)
})
- test('cleanup old trx event listeners when transaction is updated', async (assert) => {
+ test('cleanup old trx event listeners when transaction is updated', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -236,7 +236,7 @@ test.group('Adapter', (group) => {
await trx.rollback()
})
- test('use transaction client set on the model for the update', async (assert) => {
+ test('use transaction client set on the model for the update', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -268,7 +268,7 @@ test.group('Adapter', (group) => {
assert.equal(users[0].username, 'virk')
})
- test('use transaction client set on the model for the delete', async (assert) => {
+ test('use transaction client set on the model for the delete', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -299,7 +299,9 @@ test.group('Adapter', (group) => {
assert.lengthOf(users, 1)
})
- test('set primary key value when colun name is different from attribute name', async (assert) => {
+ test('set primary key value when colun name is different from attribute name', async ({
+ assert,
+ }) => {
class User extends BaseModel {
public static $table = 'users'
diff --git a/test/orm/base-model-options.spec.ts b/test/orm/base-model-options.spec.ts
index 03cc82d0..820cf290 100644
--- a/test/orm/base-model-options.spec.ts
+++ b/test/orm/base-model-options.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasOne } from '@ioc:Adonis/Lucid/Orm'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -30,24 +30,24 @@ let BaseModel: ReturnType
let app: ApplicationContract
test.group('Model options | QueryBuilder', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('query builder set model options from the query client', async (assert) => {
+ test('query builder set model options from the query client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -67,7 +67,7 @@ test.group('Model options | QueryBuilder', (group) => {
assert.deepEqual(users[0].$options!.profiler, app.profiler)
})
- test('query builder set model options when only one row is fetched', async (assert) => {
+ test('query builder set model options when only one row is fetched', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -86,7 +86,7 @@ test.group('Model options | QueryBuilder', (group) => {
assert.deepEqual(user!.$options!.profiler, app.profiler)
})
- test('query builder use transaction when updating rows', async (assert) => {
+ test('query builder use transaction when updating rows', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -112,7 +112,7 @@ test.group('Model options | QueryBuilder', (group) => {
assert.equal(usersFresh[0].username, 'virk')
})
- test('cleanup transaction reference after commit or rollback', async (assert) => {
+ test('cleanup transaction reference after commit or rollback', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -140,24 +140,24 @@ test.group('Model options | QueryBuilder', (group) => {
})
test.group('Model options | Adapter', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('use correct client when custom connection is defined', async (assert) => {
+ test('use correct client when custom connection is defined', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -175,7 +175,7 @@ test.group('Model options | Adapter', (group) => {
assert.deepEqual(user!.$options!.profiler, app.profiler)
})
- test('pass profiler to the client when defined explicitly', async (assert) => {
+ test('pass profiler to the client when defined explicitly', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -194,7 +194,7 @@ test.group('Model options | Adapter', (group) => {
assert.deepEqual(user!.$options!.profiler, profiler)
})
- test('pass custom client to query builder', async (assert) => {
+ test('pass custom client to query builder', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -213,7 +213,7 @@ test.group('Model options | Adapter', (group) => {
assert.equal(user!.$options!.connection, 'primary')
})
- test('pass transaction client to query builder', async (assert) => {
+ test('pass transaction client to query builder', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -235,24 +235,24 @@ test.group('Model options | Adapter', (group) => {
})
test.group('Model options | Model.find', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -270,7 +270,7 @@ test.group('Model options | Model.find', (group) => {
assert.deepEqual(user!.$options!.profiler, app.profiler)
})
- test('define custom profiler', async (assert) => {
+ test('define custom profiler', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -288,7 +288,7 @@ test.group('Model options | Model.find', (group) => {
assert.deepEqual(user!.$options!.profiler, profiler)
})
- test('define custom query client', async (assert) => {
+ test('define custom query client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -309,24 +309,24 @@ test.group('Model options | Model.find', (group) => {
})
test.group('Model options | Model.findOrFail', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -344,7 +344,7 @@ test.group('Model options | Model.findOrFail', (group) => {
assert.deepEqual(user.$options!.profiler, app.profiler)
})
- test('define custom profiler', async (assert) => {
+ test('define custom profiler', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -361,9 +361,11 @@ test.group('Model options | Model.findOrFail', (group) => {
const user = await User.findOrFail(1, { profiler })
assert.deepEqual(user.$options!.profiler, profiler)
+
+ await customDb.manager.closeAll()
})
- test('define custom query client', async (assert) => {
+ test('define custom query client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -384,24 +386,24 @@ test.group('Model options | Model.findOrFail', (group) => {
})
test.group('Model options | Model.findMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -419,7 +421,7 @@ test.group('Model options | Model.findMany', (group) => {
assert.deepEqual(users[0].$options!.profiler, app.profiler)
})
- test('define custom profiler', async (assert) => {
+ test('define custom profiler', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -437,7 +439,7 @@ test.group('Model options | Model.findMany', (group) => {
assert.deepEqual(users[0].$options!.profiler, profiler)
})
- test('define custom query client', async (assert) => {
+ test('define custom query client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -458,24 +460,24 @@ test.group('Model options | Model.findMany', (group) => {
})
test.group('Model options | Model.firstOrCreate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -498,7 +500,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.profiler, app.profiler)
})
- test('define custom connection when search fails', async (assert) => {
+ test('define custom connection when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -521,7 +523,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.profiler, app.profiler)
})
- test('define custom profiler', async (assert) => {
+ test('define custom profiler', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -543,7 +545,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.profiler, profiler)
})
- test('define custom profiler when search fails', async (assert) => {
+ test('define custom profiler when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -564,7 +566,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.profiler, profiler)
})
- test('define custom client', async (assert) => {
+ test('define custom client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -586,7 +588,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('define custom client when search fails', async (assert) => {
+ test('define custom client when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -608,7 +610,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('use transaction', async (assert) => {
+ test('use transaction', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -632,7 +634,7 @@ test.group('Model options | Model.firstOrCreate', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('use transaction to save when search fails', async (assert) => {
+ test('use transaction to save when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -657,24 +659,24 @@ test.group('Model options | Model.firstOrCreate', (group) => {
})
test.group('Model options | Model.fetchOrCreateMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -698,7 +700,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.deepEqual(user.$options!.profiler, app.profiler)
})
- test('define custom connection when search fails', async (assert) => {
+ test('define custom connection when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -720,7 +722,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.deepEqual(user.$options!.profiler, app.profiler)
})
- test('define custom profiler', async (assert) => {
+ test('define custom profiler', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -743,7 +745,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.deepEqual(user.$options!.profiler, profiler)
})
- test('define custom profiler when search fails', async (assert) => {
+ test('define custom profiler when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -764,7 +766,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.deepEqual(user.$options!.profiler, profiler)
})
- test('define custom client', async (assert) => {
+ test('define custom client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -787,7 +789,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('define custom client when search fails', async (assert) => {
+ test('define custom client when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -809,7 +811,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('wrap create many calls inside a transaction', async (assert) => {
+ test('wrap create many calls inside a transaction', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -839,7 +841,7 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
assert.equal(total[0].total, 0)
})
- test('use existing transaction when passed', async (assert) => {
+ test('use existing transaction when passed', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -871,24 +873,24 @@ test.group('Model options | Model.fetchOrCreateMany', (group) => {
})
test.group('Model options | Model.updateOrCreateMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define custom connection', async (assert) => {
+ test('define custom connection', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -913,7 +915,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.isUndefined(user.$trx)
})
- test('define custom connection when search fails', async (assert) => {
+ test('define custom connection when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -936,7 +938,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.isUndefined(user.$trx)
})
- test('define custom profiler', async (assert) => {
+ test('define custom profiler', async ({ assert }) => {
assert.plan(4)
class User extends BaseModel {
@@ -966,7 +968,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.isUndefined(user.$trx)
})
- test('define custom profiler when search fails', async (assert) => {
+ test('define custom profiler when search fails', async ({ assert }) => {
assert.plan(4)
class User extends BaseModel {
@@ -995,7 +997,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.isUndefined(user.$trx)
})
- test('define custom client', async (assert) => {
+ test('define custom client', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -1018,7 +1020,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('define custom client when search fails', async (assert) => {
+ test('define custom client when search fails', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -1040,7 +1042,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.deepEqual(user.$options!.connection, client.connectionName)
})
- test('wrap update many calls inside a transaction', async (assert) => {
+ test('wrap update many calls inside a transaction', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -1070,7 +1072,7 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
assert.equal(total[0].total, 0)
})
- test('use existing transaction when passed', async (assert) => {
+ test('use existing transaction when passed', async ({ assert }) => {
class User extends BaseModel {
public static $table = 'users'
@@ -1102,24 +1104,24 @@ test.group('Model options | Model.updateOrCreateMany', (group) => {
})
test.group('Model options | Query Builder Preloads', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('pass query options to preloaded models', async (assert) => {
+ test('pass query options to preloaded models', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1155,7 +1157,7 @@ test.group('Model options | Query Builder Preloads', (group) => {
assert.deepEqual(users[0].profile.$options!.profiler, app.profiler)
})
- test('use transaction client to execute preload queries', async (assert) => {
+ test('use transaction client to execute preload queries', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1194,7 +1196,7 @@ test.group('Model options | Query Builder Preloads', (group) => {
assert.deepEqual(users[0].profile.$options!.profiler, trx.profiler)
})
- test('pass profiler to preload models', async (assert) => {
+ test('pass profiler to preload models', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1232,7 +1234,7 @@ test.group('Model options | Query Builder Preloads', (group) => {
assert.deepEqual(users[0].profile.$options!.profiler, profiler)
})
- test('pass sideloaded data to preloads', async (assert) => {
+ test('pass sideloaded data to preloads', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1267,7 +1269,7 @@ test.group('Model options | Query Builder Preloads', (group) => {
assert.deepEqual(users[0].profile.$sideloaded, { id: 1 })
})
- test('custom sideloaded data on preload query must win', async (assert) => {
+ test('custom sideloaded data on preload query must win', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1307,7 +1309,7 @@ test.group('Model options | Query Builder Preloads', (group) => {
assert.deepEqual(users[0].profile.$sideloaded, { id: 2 })
})
- test('use transaction client to update preloaded rows', async (assert) => {
+ test('use transaction client to update preloaded rows', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1348,7 +1350,7 @@ test.group('Model options | Query Builder Preloads', (group) => {
assert.equal(profiles[0].displayName, 'Virk')
})
- test('cleanup transaction reference after commit or rollback', async (assert) => {
+ test('cleanup transaction reference after commit or rollback', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1393,24 +1395,24 @@ test.group('Model options | Query Builder Preloads', (group) => {
})
test.group('Model options | Model Preloads', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await cleanup()
await fs.cleanup()
await db.manager.closeAll()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('pass query options to preloaded models', async (assert) => {
+ test('pass query options to preloaded models', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1445,7 +1447,7 @@ test.group('Model options | Model Preloads', (group) => {
assert.deepEqual(user.profile.$options!.profiler, app.profiler)
})
- test('pass profiler to preload models', async (assert) => {
+ test('pass profiler to preload models', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1483,7 +1485,7 @@ test.group('Model options | Model Preloads', (group) => {
assert.deepEqual(user.profile.$options!.profiler, profiler)
})
- test('pass sideloaded data to preloads', async (assert) => {
+ test('pass sideloaded data to preloads', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1516,7 +1518,7 @@ test.group('Model options | Model Preloads', (group) => {
assert.deepEqual(user.profile.$sideloaded, { id: 1 })
})
- test('custom sideloaded data on preload query must win', async (assert) => {
+ test('custom sideloaded data on preload query must win', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/orm/base-model.spec.ts b/test/orm/base-model.spec.ts
index f385baec..4491da2b 100644
--- a/test/orm/base-model.spec.ts
+++ b/test/orm/base-model.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { DateTime } from 'luxon'
import { lodash } from '@poppinss/utils'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -62,20 +62,20 @@ let BaseModel: ReturnType
let app: ApplicationContract
test.group('Base model | boot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('ensure save method is chainable', async (assert) => {
+ test('ensure save method is chainable', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@column()
@@ -94,7 +94,7 @@ test.group('Base model | boot', (group) => {
assert.instanceOf(chained, User)
})
- test('ensure fill method is chainable', async (assert) => {
+ test('ensure fill method is chainable', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -112,7 +112,7 @@ test.group('Base model | boot', (group) => {
assert.instanceOf(chained, User)
})
- test('ensure merge method is chainable', async (assert) => {
+ test('ensure merge method is chainable', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -130,7 +130,7 @@ test.group('Base model | boot', (group) => {
assert.instanceOf(chained, User)
})
- test('ensure refresh method is chainable', async (assert) => {
+ test('ensure refresh method is chainable', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@column()
@@ -147,7 +147,7 @@ test.group('Base model | boot', (group) => {
assert.instanceOf(chained, User)
})
- test('compute table name from model name', async (assert) => {
+ test('compute table name from model name', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -160,7 +160,7 @@ test.group('Base model | boot', (group) => {
assert.equal(User.table, 'users')
})
- test('allow overriding table name', async (assert) => {
+ test('allow overriding table name', async ({ assert }) => {
class User extends BaseModel {
public static table = 'my_users'
@@ -175,7 +175,7 @@ test.group('Base model | boot', (group) => {
assert.equal(User.table, 'my_users')
})
- test('initiate all required static properties', async (assert) => {
+ test('initiate all required static properties', async ({ assert }) => {
class User extends BaseModel {}
User.boot()
@@ -184,7 +184,7 @@ test.group('Base model | boot', (group) => {
assert.deepEqual(mapToObj(User.$computedDefinitions), {})
})
- test('resolve column name from attribute name', async (assert) => {
+ test('resolve column name from attribute name', async ({ assert }) => {
class User extends BaseModel {
public static $increments = false
@@ -199,7 +199,7 @@ test.group('Base model | boot', (group) => {
assert.deepEqual(User.$keys.attributesToColumns.get('userName'), 'user_name')
})
- test('resolve serializeAs name from the attribute name', async (assert) => {
+ test('resolve serializeAs name from the attribute name', async ({ assert }) => {
class User extends BaseModel {
public static $increments = false
@@ -214,7 +214,7 @@ test.group('Base model | boot', (group) => {
assert.deepEqual(User.$keys.attributesToSerialized.get('userName'), 'user_name')
})
- test('resolve attribute name from column name', async (assert) => {
+ test('resolve attribute name from column name', async ({ assert }) => {
class User extends BaseModel {
public static $increments = false
@@ -229,7 +229,7 @@ test.group('Base model | boot', (group) => {
assert.deepEqual(User.$keys.columnsToAttributes.get('user_name'), 'userName')
})
- test('resolve serializeAs name from column name', async (assert) => {
+ test('resolve serializeAs name from column name', async ({ assert }) => {
class User extends BaseModel {
public static $increments = false
@@ -244,7 +244,7 @@ test.group('Base model | boot', (group) => {
assert.deepEqual(User.$keys.columnsToSerialized.get('user_name'), 'user_name')
})
- test('resolve attribute name from serializeAs name', async (assert) => {
+ test('resolve attribute name from serializeAs name', async ({ assert }) => {
class User extends BaseModel {
public static $increments = false
@@ -259,7 +259,7 @@ test.group('Base model | boot', (group) => {
assert.deepEqual(User.$keys.serializedToAttributes.get('user_name'), 'userName')
})
- test('resolve column name from serializeAs name', async (assert) => {
+ test('resolve column name from serializeAs name', async ({ assert }) => {
class User extends BaseModel {
public static $increments = false
@@ -276,20 +276,20 @@ test.group('Base model | boot', (group) => {
})
test.group('Base Model | options', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set connection using useConnection method', (assert) => {
+ test('set connection using useConnection method', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -302,7 +302,7 @@ test.group('Base Model | options', (group) => {
assert.deepEqual(user.$options, { connection: 'foo' })
})
- test('set connection do not overwrite profiler from the options', (assert) => {
+ test('set connection do not overwrite profiler from the options', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -320,20 +320,20 @@ test.group('Base Model | options', (group) => {
})
test.group('Base Model | getter-setters', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set property on $attributes when defined on model instance', (assert) => {
+ test('set property on $attributes when defined on model instance', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -345,7 +345,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.deepEqual(user.$attributes, { username: 'virk' })
})
- test('pass value to setter when defined', (assert) => {
+ test('pass value to setter when defined', ({ assert }) => {
class User extends BaseModel {
@column()
public set username(value: any) {
@@ -359,7 +359,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.deepEqual(user.$attributes, { username: 'VIRK' })
})
- test('set value on model instance when is not a column', (assert) => {
+ test('set value on model instance when is not a column', ({ assert }) => {
class User extends BaseModel {
public username: string
}
@@ -372,7 +372,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.equal(user.username, 'virk')
})
- test('get value from attributes', (assert) => {
+ test('get value from attributes', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -384,7 +384,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.equal(user.username, 'virk')
})
- test('rely on getter when column is defined as a getter', (assert) => {
+ test('rely on getter when column is defined as a getter', ({ assert }) => {
class User extends BaseModel {
@column()
public get username() {
@@ -398,7 +398,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.equal(user.username, 'VIRK')
})
- test('get value from model instance when is not a column', (assert) => {
+ test('get value from model instance when is not a column', ({ assert }) => {
class User extends BaseModel {
public username = 'virk'
}
@@ -408,7 +408,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.equal(user.username, 'virk')
})
- test('get value for primary key', (assert) => {
+ test('get value for primary key', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -423,7 +423,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.deepEqual(user.$primaryKeyValue, 1)
})
- test('invoke getter when accessing value using primaryKeyValue', (assert) => {
+ test('invoke getter when accessing value using primaryKeyValue', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public get id() {
@@ -440,7 +440,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.deepEqual(user.$primaryKeyValue, '1')
})
- test('invoke column serialize method when serializing model', (assert) => {
+ test('invoke column serialize method when serializing model', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public get id() {
@@ -461,7 +461,7 @@ test.group('Base Model | getter-setters', (group) => {
assert.equal(user.toJSON().username, 'VIRK')
})
- test('implement custom merge strategies using getters and setters', (assert) => {
+ test('implement custom merge strategies using getters and setters', ({ assert }) => {
class User extends BaseModel {
@column()
public get preferences(): object {
@@ -505,20 +505,20 @@ test.group('Base Model | getter-setters', (group) => {
})
test.group('Base Model | dirty', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('get dirty properties on a fresh model', (assert) => {
+ test('get dirty properties on a fresh model', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -531,7 +531,7 @@ test.group('Base Model | dirty', (group) => {
assert.isTrue(user.$isDirty)
})
- test('get empty object when model is not dirty', (assert) => {
+ test('get empty object when model is not dirty', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -547,7 +547,7 @@ test.group('Base Model | dirty', (group) => {
assert.isFalse(user.$isDirty)
})
- test('get empty object when model is not dirty with null values', (assert) => {
+ test('get empty object when model is not dirty with null values', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -563,7 +563,7 @@ test.group('Base Model | dirty', (group) => {
assert.isFalse(user.$isDirty)
})
- test('get empty object when model is not dirty with false values', (assert) => {
+ test('get empty object when model is not dirty with false values', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -579,7 +579,7 @@ test.group('Base Model | dirty', (group) => {
assert.isFalse(user.$isDirty)
})
- test('get values removed as a side-effect of fill as dirty', async (assert) => {
+ test('get values removed as a side-effect of fill as dirty', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@column()
@@ -605,24 +605,24 @@ test.group('Base Model | dirty', (group) => {
})
test.group('Base Model | persist', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('persist model with the column name', async (assert) => {
+ test('persist model with the column name', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -661,7 +661,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { username: 'virk', fullName: 'H virk', id: 1 })
})
- test('merge adapter insert return value with attributes', async (assert) => {
+ test('merge adapter insert return value with attributes', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -695,7 +695,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { username: 'virk', id: 1 })
})
- test('do not merge adapter results when not part of model columns', async (assert) => {
+ test('do not merge adapter results when not part of model columns', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -726,7 +726,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { username: 'virk' })
})
- test('issue update when model has already been persisted', async (assert) => {
+ test('issue update when model has already been persisted', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -755,7 +755,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { username: 'virk' })
})
- test('merge return values from update', async (assert) => {
+ test('merge return values from update', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -791,7 +791,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { username: 'virk', updatedAt: '2019-11-20' })
})
- test('do not issue update when model is not dirty', async (assert) => {
+ test('do not issue update when model is not dirty', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -815,7 +815,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, {})
})
- test('refresh model instance', async (assert) => {
+ test('refresh model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -844,7 +844,7 @@ test.group('Base Model | persist', (group) => {
assert.isDefined(user.updatedAt)
})
- test('refresh model instance inside a transaction', async (assert) => {
+ test('refresh model instance inside a transaction', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -889,7 +889,7 @@ test.group('Base Model | persist', (group) => {
assert.equal(user.username, 'virk')
})
- test('raise exception when attempted to refresh deleted row', async (assert) => {
+ test('raise exception when attempted to refresh deleted row', async ({ assert }) => {
assert.plan(4)
class User extends BaseModel {
@@ -923,7 +923,7 @@ test.group('Base Model | persist', (group) => {
}
})
- test('invoke column prepare method before passing values to the adapter', async (assert) => {
+ test('invoke column prepare method before passing values to the adapter', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -955,7 +955,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { username: 'virk', fullName: 'H virk' })
})
- test('send values mutated by the hooks to the adapter', async (assert) => {
+ test('send values mutated by the hooks to the adapter', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -987,7 +987,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { fullName: 'Foo' })
})
- test('allow datetime column value to be null', async (assert) => {
+ test('allow datetime column value to be null', async ({ assert }) => {
assert.plan(3)
const adapter = new FakeAdapter()
@@ -1017,7 +1017,7 @@ test.group('Base Model | persist', (group) => {
assert.deepEqual(user.$original, { createdAt: null })
})
- test('assign local id to the model', async (assert) => {
+ test('assign local id to the model', async ({ assert }) => {
class User extends BaseModel {
public static table = 'uuid_users'
public static selfAssignPrimaryKey = true
@@ -1056,7 +1056,7 @@ test.group('Base Model | persist', (group) => {
assert.equal(user.id.toLocaleLowerCase(), uuid)
})
- test('perform update query when local primary key is updated', async (assert) => {
+ test('perform update query when local primary key is updated', async ({ assert }) => {
class User extends BaseModel {
public static table = 'uuid_users'
public static selfAssignPrimaryKey = true
@@ -1094,7 +1094,7 @@ test.group('Base Model | persist', (group) => {
})
test.group('Self assign primary key', () => {
- test('send primary value during insert to the adapter', async (assert) => {
+ test('send primary value during insert to the adapter', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -1128,7 +1128,7 @@ test.group('Self assign primary key', () => {
await user.save()
})
- test('update primary key when changed', async (assert) => {
+ test('update primary key when changed', async ({ assert }) => {
assert.plan(3)
const adapter = new FakeAdapter()
@@ -1173,20 +1173,20 @@ test.group('Self assign primary key', () => {
})
test.group('Base Model | create from adapter results', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('create model instance using $createFromAdapterResult method', async (assert) => {
+ test('create model instance using $createFromAdapterResult method', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1205,7 +1205,7 @@ test.group('Base Model | create from adapter results', (group) => {
assert.deepEqual(user!.$original, { username: 'virk' })
})
- test('set options on model instance passed to $createFromAdapterResult', async (assert) => {
+ test('set options on model instance passed to $createFromAdapterResult', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1224,7 +1224,7 @@ test.group('Base Model | create from adapter results', (group) => {
assert.deepEqual(user!.$original, { username: 'virk' })
})
- test('return null from $createFromAdapterResult when input is not object', (assert) => {
+ test('return null from $createFromAdapterResult when input is not object', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1237,7 +1237,9 @@ test.group('Base Model | create from adapter results', (group) => {
assert.isNull(user)
})
- test('create multiple model instance using $createMultipleFromAdapterResult', async (assert) => {
+ test('create multiple model instance using $createMultipleFromAdapterResult', async ({
+ assert,
+ }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1265,7 +1267,7 @@ test.group('Base Model | create from adapter results', (group) => {
assert.deepEqual(users[1].$original, { username: 'prasan' })
})
- test('pass model options via $createMultipleFromAdapterResult', async (assert) => {
+ test('pass model options via $createMultipleFromAdapterResult', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1297,7 +1299,7 @@ test.group('Base Model | create from adapter results', (group) => {
assert.deepEqual(users[1].$original, { username: 'prasan' })
})
- test('skip rows that are not valid objects inside array', async (assert) => {
+ test('skip rows that are not valid objects inside array', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1319,7 +1321,7 @@ test.group('Base Model | create from adapter results', (group) => {
assert.deepEqual(users[0].$original, { username: 'virk', fullName: 'H virk' })
})
- test('invoke column consume method', async (assert) => {
+ test('invoke column consume method', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1339,7 +1341,7 @@ test.group('Base Model | create from adapter results', (group) => {
assert.deepEqual(user!.$original, { fullName: 'VIRK' })
})
- test('original and attributes should not be shared', async (assert) => {
+ test('original and attributes should not be shared', async ({ assert }) => {
class User extends BaseModel {
@column()
public user: {
@@ -1363,20 +1365,20 @@ test.group('Base Model | create from adapter results', (group) => {
})
test.group('Base Model | delete', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('delete model instance using adapter', async (assert) => {
+ test('delete model instance using adapter', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -1398,7 +1400,7 @@ test.group('Base Model | delete', (group) => {
assert.isTrue(user.$isDeleted)
})
- test('raise exception when trying to mutate model after deletion', async (assert) => {
+ test('raise exception when trying to mutate model after deletion', async ({ assert }) => {
const adapter = new FakeAdapter()
assert.plan(1)
@@ -1421,7 +1423,7 @@ test.group('Base Model | delete', (group) => {
})
test.group('Base Model | serializeAttributes', () => {
- test('serialize attributes', async (assert) => {
+ test('serialize attributes', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1433,7 +1435,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(), { username: 'virk' })
})
- test('invoke custom serialize method when serializing attributes', async (assert) => {
+ test('invoke custom serialize method when serializing attributes', async ({ assert }) => {
class User extends BaseModel {
@column({ serialize: (value) => value.toUpperCase() })
public username: string
@@ -1445,7 +1447,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(), { username: 'VIRK' })
})
- test('use custom serializeAs key', async (assert) => {
+ test('use custom serializeAs key', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: 'uname' })
public username: string
@@ -1457,7 +1459,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(), { uname: 'virk' })
})
- test('do not serialize when serializeAs key is null', async (assert) => {
+ test('do not serialize when serializeAs key is null', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: null })
public username: string
@@ -1469,7 +1471,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(), {})
})
- test('pick fields during serialization', async (assert) => {
+ test('pick fields during serialization', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1485,7 +1487,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(['id']), { id: '1' })
})
- test('ignore fields under omit', async (assert) => {
+ test('ignore fields under omit', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1506,7 +1508,7 @@ test.group('Base Model | serializeAttributes', () => {
)
})
- test('use omit and pick together', async (assert) => {
+ test('use omit and pick together', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1528,7 +1530,9 @@ test.group('Base Model | serializeAttributes', () => {
)
})
- test('ignore fields that has serializeAs = null, even when part of pick array', async (assert) => {
+ test('ignore fields that has serializeAs = null, even when part of pick array', async ({
+ assert,
+ }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1544,7 +1548,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(['id']), {})
})
- test('do not invoke custom serialize method when raw flag is on', async (assert) => {
+ test('do not invoke custom serialize method when raw flag is on', async ({ assert }) => {
class User extends BaseModel {
@column({ serialize: (value) => value.toUpperCase() })
public username: string
@@ -1556,7 +1560,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(undefined, true), { username: 'virk' })
})
- test('use custom serializeAs key when raw flag is on', async (assert) => {
+ test('use custom serializeAs key when raw flag is on', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: 'uname' })
public username: string
@@ -1568,7 +1572,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(undefined, true), { uname: 'virk' })
})
- test('do not serialize with serializeAs = null, when raw flag is on', async (assert) => {
+ test('do not serialize with serializeAs = null, when raw flag is on', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: null })
public username: string
@@ -1580,7 +1584,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(undefined, true), {})
})
- test('cherry pick fields in raw mode', async (assert) => {
+ test('cherry pick fields in raw mode', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1596,7 +1600,7 @@ test.group('Base Model | serializeAttributes', () => {
assert.deepEqual(user.serializeAttributes(['id'], true), { id: '1' })
})
- test('ignore fields under omit array in raw mode', async (assert) => {
+ test('ignore fields under omit array in raw mode', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1623,7 +1627,7 @@ test.group('Base Model | serializeAttributes', () => {
})
test.group('Base Model | serializeRelations', () => {
- test('serialize relations', async (assert) => {
+ test('serialize relations', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1654,7 +1658,7 @@ test.group('Base Model | serializeRelations', () => {
})
})
- test('use custom serializeAs key when raw flag is on', async (assert) => {
+ test('use custom serializeAs key when raw flag is on', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1685,7 +1689,7 @@ test.group('Base Model | serializeRelations', () => {
})
})
- test('do not serialize relations when serializeAs is null', async (assert) => {
+ test('do not serialize relations when serializeAs is null', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1711,7 +1715,7 @@ test.group('Base Model | serializeRelations', () => {
assert.deepEqual(user.serializeRelations(), {})
})
- test('do not recursively serialize relations when raw is true', async (assert) => {
+ test('do not recursively serialize relations when raw is true', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1739,7 +1743,7 @@ test.group('Base Model | serializeRelations', () => {
})
})
- test('use custom serializeAs key when raw flag is on', async (assert) => {
+ test('use custom serializeAs key when raw flag is on', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1767,7 +1771,9 @@ test.group('Base Model | serializeRelations', () => {
})
})
- test('do not serialize relations with serializeAs is null when raw flag is on', async (assert) => {
+ test('do not serialize relations with serializeAs is null when raw flag is on', async ({
+ assert,
+ }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1793,7 +1799,7 @@ test.group('Base Model | serializeRelations', () => {
assert.deepEqual(user.serializeRelations(undefined, true), {})
})
- test('cherry pick relationship fields', async (assert) => {
+ test('cherry pick relationship fields', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1830,7 +1836,9 @@ test.group('Base Model | serializeRelations', () => {
)
})
- test('select all fields when no custom fields are defined for a relationship', async (assert) => {
+ test('select all fields when no custom fields are defined for a relationship', async ({
+ assert,
+ }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1866,7 +1874,9 @@ test.group('Base Model | serializeRelations', () => {
)
})
- test('do not select any fields when relationship fields is an empty array', async (assert) => {
+ test('do not select any fields when relationship fields is an empty array', async ({
+ assert,
+ }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -1903,20 +1913,20 @@ test.group('Base Model | serializeRelations', () => {
})
test.group('Base Model | toJSON', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('convert model to its JSON representation', async (assert) => {
+ test('convert model to its JSON representation', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1928,7 +1938,7 @@ test.group('Base Model | toJSON', (group) => {
assert.deepEqual(user.toJSON(), { username: 'virk' })
})
- test('use serializeAs key when converting model to JSON', async (assert) => {
+ test('use serializeAs key when converting model to JSON', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: 'theUsername' })
public username: string
@@ -1940,7 +1950,7 @@ test.group('Base Model | toJSON', (group) => {
assert.deepEqual(user.toJSON(), { theUsername: 'virk' })
})
- test('do not serialize when serializeAs is set to null', async (assert) => {
+ test('do not serialize when serializeAs is set to null', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: null })
public username: string
@@ -1952,7 +1962,7 @@ test.group('Base Model | toJSON', (group) => {
assert.deepEqual(user.toJSON(), {})
})
- test('add computed properties to toJSON result', async (assert) => {
+ test('add computed properties to toJSON result', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1969,7 +1979,7 @@ test.group('Base Model | toJSON', (group) => {
assert.deepEqual(user.toJSON(), { username: 'virk', fullName: 'VIRK' })
})
- test('do not add computed property when it returns undefined', async (assert) => {
+ test('do not add computed property when it returns undefined', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -1986,7 +1996,7 @@ test.group('Base Model | toJSON', (group) => {
assert.deepEqual(user.toJSON(), { username: 'virk' })
})
- test('cherry pick keys during serialization', async (assert) => {
+ test('cherry pick keys during serialization', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2008,7 +2018,7 @@ test.group('Base Model | toJSON', (group) => {
)
})
- test('serialize extras', async (assert) => {
+ test('serialize extras', async ({ assert }) => {
class User extends BaseModel {
public serializeExtras = true
@@ -2034,7 +2044,7 @@ test.group('Base Model | toJSON', (group) => {
})
})
- test('define serialize extras as a function', async (assert) => {
+ test('define serialize extras as a function', async ({ assert }) => {
class User extends BaseModel {
public serializeExtras() {
return {
@@ -2066,7 +2076,7 @@ test.group('Base Model | toJSON', (group) => {
})
})
- test('do not serialize undefined values', async (assert) => {
+ test('do not serialize undefined values', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2081,7 +2091,7 @@ test.group('Base Model | toJSON', (group) => {
assert.deepEqual(user.toJSON(), { username: 'virk' })
})
- test('serialize null values', async (assert) => {
+ test('serialize null values', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2099,20 +2109,20 @@ test.group('Base Model | toJSON', (group) => {
})
test.group('BaseModel | cache', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('cache getter value', (assert) => {
+ test('cache getter value', ({ assert }) => {
let invokedCounter = 0
class User extends BaseModel {
@@ -2136,7 +2146,7 @@ test.group('BaseModel | cache', (group) => {
assert.equal(invokedCounter, 1)
})
- test('re-call getter function when attribute value changes', (assert) => {
+ test('re-call getter function when attribute value changes', ({ assert }) => {
let invokedCounter = 0
class User extends BaseModel {
@@ -2165,20 +2175,20 @@ test.group('BaseModel | cache', (group) => {
})
test.group('BaseModel | fill/merge', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('fill model instance with bulk attributes', (assert) => {
+ test('fill model instance with bulk attributes', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2189,7 +2199,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { username: 'virk' })
})
- test('raise error when extra properties are defined', (assert) => {
+ test('raise error when extra properties are defined', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2197,13 +2207,13 @@ test.group('BaseModel | fill/merge', (group) => {
const user = new User()
const fn = () => user.fill({ username: 'virk', isAdmin: true } as any)
- assert.throw(
+ assert.throws(
fn,
'Cannot define "isAdmin" on "User" model, since it is not defined as a model property'
)
})
- test('set extra properties via fill when allowExtraProperties is true', (assert) => {
+ test('set extra properties via fill when allowExtraProperties is true', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2215,7 +2225,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$extras, { isAdmin: true })
})
- test('overwrite existing values when using fill', (assert) => {
+ test('overwrite existing values when using fill', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2232,7 +2242,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { username: 'virk' })
})
- test('merge to existing when using merge instead of fill', (assert) => {
+ test('merge to existing when using merge instead of fill', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2249,7 +2259,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { username: 'virk', age: 22 })
})
- test('set properties with explicit undefined values', (assert) => {
+ test('set properties with explicit undefined values', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2266,7 +2276,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { username: 'virk', age: undefined })
})
- test('invoke setter when using fill', (assert) => {
+ test('invoke setter when using fill', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2289,7 +2299,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { username: 'virk', age: 23 })
})
- test('fill using the column name', (assert) => {
+ test('fill using the column name', ({ assert }) => {
class User extends BaseModel {
@column()
public firstName: string
@@ -2300,7 +2310,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { firstName: 'virk' })
})
- test('invoke setter during fill when using column name', (assert) => {
+ test('invoke setter during fill when using column name', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2320,7 +2330,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.deepEqual(user.$attributes, { age: 23 })
})
- test('merge set non-column model properties', (assert) => {
+ test('merge set non-column model properties', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2340,7 +2350,7 @@ test.group('BaseModel | fill/merge', (group) => {
assert.equal(user.foo, 'bar')
})
- test('merge set non-column model properties with inheritance', (assert) => {
+ test('merge set non-column model properties with inheritance', ({ assert }) => {
class Super extends BaseModel {
public foo: string
}
@@ -2364,20 +2374,20 @@ test.group('BaseModel | fill/merge', (group) => {
})
test.group('Base | apdater', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('pass model instance with attributes to the adapter insert method', async (assert) => {
+ test('pass model instance with attributes to the adapter insert method', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -2400,7 +2410,7 @@ test.group('Base | apdater', (group) => {
])
})
- test('pass model instance with attributes to the adapter update method', async (assert) => {
+ test('pass model instance with attributes to the adapter update method', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -2431,7 +2441,7 @@ test.group('Base | apdater', (group) => {
])
})
- test('pass model instance to the adapter delete method', async (assert) => {
+ test('pass model instance to the adapter delete method', async ({ assert }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@@ -2459,7 +2469,9 @@ test.group('Base | apdater', (group) => {
])
})
- test('fill model instance with bulk attributes via column name is different', async (assert) => {
+ test('fill model instance with bulk attributes via column name is different', async ({
+ assert,
+ }) => {
const adapter = new FakeAdapter()
class User extends BaseModel {
@column({ columnName: 'first_name' })
@@ -2483,20 +2495,20 @@ test.group('Base | apdater', (group) => {
})
test.group('Base Model | sideloaded', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('define sideloaded properties using $consumeAdapterResults method', (assert) => {
+ test('define sideloaded properties using $consumeAdapterResults method', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2509,7 +2521,7 @@ test.group('Base Model | sideloaded', (group) => {
assert.deepEqual(user.$sideloaded, { loggedInUser: { id: 1 } })
})
- test('define sideloaded properties using $createFromAdapterResult method', (assert) => {
+ test('define sideloaded properties using $createFromAdapterResult method', ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2520,7 +2532,9 @@ test.group('Base Model | sideloaded', (group) => {
assert.deepEqual(user.$sideloaded, { loggedInUser: { id: 1 } })
})
- test('define sideloaded properties using $createMultipleFromAdapterResult method', (assert) => {
+ test('define sideloaded properties using $createMultipleFromAdapterResult method', ({
+ assert,
+ }) => {
class User extends BaseModel {
@column()
public username: string
@@ -2542,20 +2556,20 @@ test.group('Base Model | sideloaded', (group) => {
})
test.group('Base Model | relations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set hasOne relation', async (assert) => {
+ test('set hasOne relation', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2582,7 +2596,7 @@ test.group('Base Model | relations', (group) => {
assert.instanceOf(user.$preloaded.profile, Profile)
})
- test('return undefined when relation is not preloaded', (assert) => {
+ test('return undefined when relation is not preloaded', ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -2608,7 +2622,7 @@ test.group('Base Model | relations', (group) => {
assert.deepEqual(user.$preloaded, {})
})
- test('serialize relation toJSON', async (assert) => {
+ test('serialize relation toJSON', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2639,7 +2653,7 @@ test.group('Base Model | relations', (group) => {
})
})
- test('cherry pick relationship keys during serialize', async (assert) => {
+ test('cherry pick relationship keys during serialize', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2683,7 +2697,7 @@ test.group('Base Model | relations', (group) => {
)
})
- test('cherry pick nested relationship keys during serialize', async (assert) => {
+ test('cherry pick nested relationship keys during serialize', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2746,7 +2760,7 @@ test.group('Base Model | relations', (group) => {
)
})
- test('serialize relation toJSON with custom serializeAs key', async (assert) => {
+ test('serialize relation toJSON with custom serializeAs key', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2777,7 +2791,7 @@ test.group('Base Model | relations', (group) => {
})
})
- test('push relationship', async (assert) => {
+ test('push relationship', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2810,7 +2824,7 @@ test.group('Base Model | relations', (group) => {
})
})
- test('push relationship to existing list', async (assert) => {
+ test('push relationship to existing list', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2847,7 +2861,7 @@ test.group('Base Model | relations', (group) => {
})
})
- test('push an array of relationships', async (assert) => {
+ test('push an array of relationships', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2886,7 +2900,7 @@ test.group('Base Model | relations', (group) => {
})
})
- test('raise error when pushing an array of relationships for hasOne', async (assert) => {
+ test('raise error when pushing an array of relationships for hasOne', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2912,10 +2926,10 @@ test.group('Base Model | relations', (group) => {
const profile1 = await Profile.create({ username: 'virk' })
const fn = () => user.$pushRelated('profile', [profile, profile1] as any)
- assert.throw(fn, '"User.profile" cannot reference more than one instance of "Profile" model')
+ assert.throws(fn, '"User.profile" cannot reference more than one instance of "Profile" model')
})
- test('raise error when setting single relationships for hasMany', async (assert) => {
+ test('raise error when setting single relationships for hasMany', async ({ assert }) => {
const adapter = new FakeAdapter()
class Profile extends BaseModel {
@column()
@@ -2940,29 +2954,29 @@ test.group('Base Model | relations', (group) => {
const profile = await Profile.create({ username: 'virk' })
const fn = () => user.$setRelated('profiles', profile as any)
- assert.throw(fn, '"User.profiles" must be an array when setting "hasMany" relationship')
+ assert.throws(fn, '"User.profiles" must be an array when setting "hasMany" relationship')
})
})
test.group('Base Model | fetch', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('find using the primary key', async (assert) => {
+ test('find using the primary key', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2981,7 +2995,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(user!.$primaryKeyValue, 1)
})
- test('raise exception when row is not found', async (assert) => {
+ test('raise exception when row is not found', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@column({ isPrimary: true })
@@ -3001,7 +3015,7 @@ test.group('Base Model | fetch', (group) => {
}
})
- test('find many using the primary key', async (assert) => {
+ test('find many using the primary key', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3024,7 +3038,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(users[1].$primaryKeyValue, 1)
})
- test('return the existing row when search criteria matches', async (assert) => {
+ test('return the existing row when search criteria matches', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3047,7 +3061,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(user!.$primaryKeyValue, 1)
})
- test("create new row when search criteria doesn't match", async (assert) => {
+ test("create new row when search criteria doesn't match", async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3073,7 +3087,9 @@ test.group('Base Model | fetch', (group) => {
assert.equal(user!.userName, 'nikk')
})
- test('return the existing row when search criteria matches using firstOrNew', async (assert) => {
+ test('return the existing row when search criteria matches using firstOrNew', async ({
+ assert,
+ }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3096,7 +3112,9 @@ test.group('Base Model | fetch', (group) => {
assert.equal(user!.$primaryKeyValue, 1)
})
- test("instantiate new row when search criteria doesn't match using firstOrNew", async (assert) => {
+ test("instantiate new row when search criteria doesn't match using firstOrNew", async ({
+ assert,
+ }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3122,7 +3140,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(user!.userName, 'nikk')
})
- test('update the existing row when search criteria matches', async (assert) => {
+ test('update the existing row when search criteria matches', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3149,7 +3167,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(users[0].points, 20)
})
- test('lock row for update to handle concurrent requests', async (assert) => {
+ test('lock row for update to handle concurrent requests', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3200,7 +3218,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(users[0].points, 22)
})
- test('execute updateOrCreate update action inside a transaction', async (assert) => {
+ test('execute updateOrCreate update action inside a transaction', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3233,7 +3251,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(users[0].points, 0)
})
- test('create a new row when search criteria fails', async (assert) => {
+ test('create a new row when search criteria fails', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3265,7 +3283,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(users[1].points, 20)
})
- test('execute updateOrCreate create action inside a transaction', async (assert) => {
+ test('execute updateOrCreate create action inside a transaction', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3298,7 +3316,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(users[0].points, 0)
})
- test('persist records to db when find call returns zero rows', async (assert) => {
+ test('persist records to db when find call returns zero rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3345,7 +3363,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 3)
})
- test('sync records by avoiding duplicates', async (assert) => {
+ test('sync records by avoiding duplicates', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3401,7 +3419,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 3)
})
- test('wrap create calls inside a transaction', async (assert) => {
+ test('wrap create calls inside a transaction', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3450,7 +3468,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 1)
})
- test('handle columns with different cast key name', async (assert) => {
+ test('handle columns with different cast key name', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3506,7 +3524,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 3)
})
- test('raise exception when one or more rows fails', async (assert) => {
+ test('raise exception when one or more rows fails', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -3557,7 +3575,9 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 1)
})
- test('raise exception when value of unique key inside payload is undefined', async (assert) => {
+ test('raise exception when value of unique key inside payload is undefined', async ({
+ assert,
+ }) => {
assert.plan(2)
class User extends BaseModel {
@@ -3601,7 +3621,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 1)
})
- test('raise exception when key is not defined on the model', async (assert) => {
+ test('raise exception when key is not defined on the model', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -3642,7 +3662,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 1)
})
- test('persist records to db when find call returns zero rows', async (assert) => {
+ test('persist records to db when find call returns zero rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3689,7 +3709,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 3)
})
- test('update records and avoid duplicates', async (assert) => {
+ test('update records and avoid duplicates', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3746,7 +3766,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 3)
})
- test('use multiple keys to predicate a row as unique', async (assert) => {
+ test('use multiple keys to predicate a row as unique', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3812,7 +3832,7 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 4)
})
- test('wrap create calls inside a transaction using updateOrCreateMany', async (assert) => {
+ test('wrap create calls inside a transaction using updateOrCreateMany', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3861,7 +3881,9 @@ test.group('Base Model | fetch', (group) => {
assert.lengthOf(usersList, 1)
})
- test('wrap update calls inside a custom transaction using updateOrCreateMany', async (assert) => {
+ test('wrap update calls inside a custom transaction using updateOrCreateMany', async ({
+ assert,
+ }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3912,7 +3934,7 @@ test.group('Base Model | fetch', (group) => {
assert.equal(usersList[0].points, 10)
})
- test('handle concurrent update calls using updateOrCreateMany', async (assert) => {
+ test('handle concurrent update calls using updateOrCreateMany', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3966,24 +3988,24 @@ test.group('Base Model | fetch', (group) => {
})
test.group('Base Model | hooks', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('invoke before and after create hooks', async (assert) => {
+ test('invoke before and after create hooks', async ({ assert }) => {
assert.plan(9)
const stack: string[] = []
@@ -4037,7 +4059,7 @@ test.group('Base Model | hooks', (group) => {
])
})
- test('abort create when before hook raises exception', async (assert) => {
+ test('abort create when before hook raises exception', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -4090,7 +4112,7 @@ test.group('Base Model | hooks', (group) => {
}
})
- test('listen for trx on after save commit', async (assert) => {
+ test('listen for trx on after save commit', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -4123,7 +4145,7 @@ test.group('Base Model | hooks', (group) => {
await trx.commit()
})
- test('listen for trx on after save rollback', async (assert) => {
+ test('listen for trx on after save rollback', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -4156,7 +4178,7 @@ test.group('Base Model | hooks', (group) => {
await trx.rollback()
})
- test('invoke before and after update hooks', async (assert) => {
+ test('invoke before and after update hooks', async ({ assert }) => {
assert.plan(10)
class User extends BaseModel {
@@ -4205,7 +4227,7 @@ test.group('Base Model | hooks', (group) => {
assert.equal(users[0].username, 'nikk')
})
- test('abort update when before hook raises exception', async (assert) => {
+ test('abort update when before hook raises exception', async ({ assert }) => {
assert.plan(5)
class User extends BaseModel {
@@ -4264,7 +4286,7 @@ test.group('Base Model | hooks', (group) => {
assert.equal(users[0].username, 'virk')
})
- test('invoke before and after delete hooks', async (assert) => {
+ test('invoke before and after delete hooks', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -4296,7 +4318,7 @@ test.group('Base Model | hooks', (group) => {
assert.equal(usersCount[0].total, 0)
})
- test('abort delete when before hook raises exception', async (assert) => {
+ test('abort delete when before hook raises exception', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -4340,7 +4362,7 @@ test.group('Base Model | hooks', (group) => {
assert.equal(usersCount[0].total, 1)
})
- test('invoke before and after fetch hooks', async (assert) => {
+ test('invoke before and after fetch hooks', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -4421,7 +4443,7 @@ test.group('Base Model | hooks', (group) => {
await User.query().del()
})
- test('invoke before and after find hooks', async (assert) => {
+ test('invoke before and after find hooks', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -4449,7 +4471,7 @@ test.group('Base Model | hooks', (group) => {
await User.find(1)
})
- test('invoke before and after find hooks when .first method is used', async (assert) => {
+ test('invoke before and after find hooks when .first method is used', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -4477,7 +4499,7 @@ test.group('Base Model | hooks', (group) => {
await User.query().where('id', 1).first()
})
- test('invoke before and after paginate hooks', async (assert) => {
+ test('invoke before and after paginate hooks', async ({ assert }) => {
assert.plan(5)
class User extends BaseModel {
@@ -4511,7 +4533,7 @@ test.group('Base Model | hooks', (group) => {
await User.query().paginate(1)
})
- test('invoke before and after fetch hooks on paginate', async (assert) => {
+ test('invoke before and after fetch hooks on paginate', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -4565,7 +4587,7 @@ test.group('Base Model | hooks', (group) => {
await User.query().pojo().paginate(1)
})
- test('@regression resolve update keys when an object is passed', async (assert) => {
+ test('@regression resolve update keys when an object is passed', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4584,7 +4606,7 @@ test.group('Base Model | hooks', (group) => {
assert.equal(users[0].username, 'nikk')
})
- test('@regression resolve update keys when a key value pair is passed', async (assert) => {
+ test('@regression resolve update keys when a key value pair is passed', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4605,20 +4627,20 @@ test.group('Base Model | hooks', (group) => {
})
test.group('Base model | extend', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('extend model query builder', async (assert) => {
+ test('extend model query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4644,7 +4666,7 @@ test.group('Base model | extend', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('extend model insert query builder', async (assert) => {
+ test('extend model insert query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4680,24 +4702,24 @@ test.group('Base model | extend', (group) => {
})
test.group('Base Model | aggregates', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('count *', async (assert) => {
+ test('count *', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4724,7 +4746,7 @@ test.group('Base Model | aggregates', (group) => {
)
})
- test('count * distinct', async (assert) => {
+ test('count * distinct', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4753,24 +4775,24 @@ test.group('Base Model | aggregates', (group) => {
})
test.group('Base Model | date', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define date column', async (assert) => {
+ test('define date column', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4789,7 +4811,7 @@ test.group('Base Model | date', (group) => {
})
})
- test('define date column and turn on autoCreate flag', async (assert) => {
+ test('define date column and turn on autoCreate flag', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4808,7 +4830,7 @@ test.group('Base Model | date', (group) => {
})
})
- test('define date column and turn on autoUpdate flag', async (assert) => {
+ test('define date column and turn on autoUpdate flag', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4827,7 +4849,7 @@ test.group('Base Model | date', (group) => {
})
})
- test('initiate date column values with current date when missing', async (assert) => {
+ test('initiate date column values with current date when missing', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -4853,7 +4875,9 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('do initiate date column values with current date when autoCreate is off', async (assert) => {
+ test('do initiate date column values with current date when autoCreate is off', async ({
+ assert,
+ }) => {
assert.plan(2)
const adapter = new FakeAdapter()
@@ -4883,7 +4907,7 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('always update date column value when autoUpdate is on', async (assert) => {
+ test('always update date column value when autoUpdate is on', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -4912,7 +4936,7 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('format date instance to string before sending to the adapter', async (assert) => {
+ test('format date instance to string before sending to the adapter', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -4937,7 +4961,7 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('leave date untouched when it is defined as string', async (assert) => {
+ test('leave date untouched when it is defined as string', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -4963,7 +4987,7 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('do not attempt to format undefined values', async (assert) => {
+ test('do not attempt to format undefined values', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -4988,7 +5012,7 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('raise error when date column value is unprocessable', async (assert) => {
+ test('raise error when date column value is unprocessable', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5019,7 +5043,7 @@ test.group('Base Model | date', (group) => {
}
})
- test('raise error when datetime is invalid', async (assert) => {
+ test('raise error when datetime is invalid', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5047,7 +5071,7 @@ test.group('Base Model | date', (group) => {
}
})
- test('allow overriding prepare method', async (assert) => {
+ test('allow overriding prepare method', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5075,7 +5099,7 @@ test.group('Base Model | date', (group) => {
await user.save()
})
- test('convert date to datetime instance during fetch', async (assert) => {
+ test('convert date to datetime instance during fetch', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5092,7 +5116,7 @@ test.group('Base Model | date', (group) => {
assert.instanceOf(user!.createdAt, DateTime)
})
- test('ignore null or empty values during fetch', async (assert) => {
+ test('ignore null or empty values during fetch', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5109,7 +5133,7 @@ test.group('Base Model | date', (group) => {
assert.isNull(user!.updatedAt)
})
- test('convert date to toISODate during serialize', async (assert) => {
+ test('convert date to toISODate during serialize', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5129,7 +5153,7 @@ test.group('Base Model | date', (group) => {
assert.match(user!.toJSON().created_at, /\d{4}-\d{2}-\d{2}/)
})
- test('do not attempt to serialize, when already a string', async (assert) => {
+ test('do not attempt to serialize, when already a string', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5156,24 +5180,24 @@ test.group('Base Model | date', (group) => {
})
test.group('Base Model | datetime', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('define datetime column', async (assert) => {
+ test('define datetime column', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5192,7 +5216,7 @@ test.group('Base Model | datetime', (group) => {
})
})
- test('define datetime column and turn on autoCreate flag', async (assert) => {
+ test('define datetime column and turn on autoCreate flag', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5211,7 +5235,7 @@ test.group('Base Model | datetime', (group) => {
})
})
- test('define datetime column and turn on autoUpdate flag', async (assert) => {
+ test('define datetime column and turn on autoUpdate flag', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5230,7 +5254,7 @@ test.group('Base Model | datetime', (group) => {
})
})
- test('initiate datetime column values with current date when missing', async (assert) => {
+ test('initiate datetime column values with current date when missing', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5261,7 +5285,7 @@ test.group('Base Model | datetime', (group) => {
)
})
- test('ignore undefined values', async (assert) => {
+ test('ignore undefined values', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5287,7 +5311,7 @@ test.group('Base Model | datetime', (group) => {
await user.save()
})
- test('ignore string values', async (assert) => {
+ test('ignore string values', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5315,7 +5339,7 @@ test.group('Base Model | datetime', (group) => {
await user.save()
})
- test('raise error when datetime column value is unprocessable', async (assert) => {
+ test('raise error when datetime column value is unprocessable', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5346,7 +5370,7 @@ test.group('Base Model | datetime', (group) => {
}
})
- test('allow overriding prepare method', async (assert) => {
+ test('allow overriding prepare method', async ({ assert }) => {
assert.plan(1)
const adapter = new FakeAdapter()
@@ -5374,7 +5398,7 @@ test.group('Base Model | datetime', (group) => {
await user.save()
})
- test('convert timestamp to datetime instance during fetch', async (assert) => {
+ test('convert timestamp to datetime instance during fetch', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5391,7 +5415,7 @@ test.group('Base Model | datetime', (group) => {
assert.instanceOf(user!.createdAt, DateTime)
})
- test('ignore null or empty values during fetch', async (assert) => {
+ test('ignore null or empty values during fetch', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5408,7 +5432,7 @@ test.group('Base Model | datetime', (group) => {
assert.isNull(user!.updatedAt)
})
- test('always set datetime value when autoUpdate is true', async (assert) => {
+ test('always set datetime value when autoUpdate is true', async ({ assert }) => {
assert.plan(2)
const adapter = new FakeAdapter()
@@ -5437,7 +5461,7 @@ test.group('Base Model | datetime', (group) => {
await user.save()
})
- test('do not set autoUpdate field datetime when model is not dirty', async (assert) => {
+ test('do not set autoUpdate field datetime when model is not dirty', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5458,7 +5482,7 @@ test.group('Base Model | datetime', (group) => {
assert.equal(originalDateTimeString, user.joinedAt.toString())
})
- test('set datetime when model is dirty but after invoking a hook', async (assert) => {
+ test('set datetime when model is dirty but after invoking a hook', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5489,7 +5513,7 @@ test.group('Base Model | datetime', (group) => {
assert.notEqual(originalDateTimeString, user.joinedAt.toString())
})
- test('convert datetime to toISO during serialize', async (assert) => {
+ test('convert datetime to toISO during serialize', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5516,7 +5540,7 @@ test.group('Base Model | datetime', (group) => {
)
})
- test('do not attempt to serialize, when already a string', async (assert) => {
+ test('do not attempt to serialize, when already a string', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5547,24 +5571,24 @@ test.group('Base Model | datetime', (group) => {
})
test.group('Base Model | paginate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('paginate through rows', async (assert) => {
+ test('paginate through rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5605,7 +5629,7 @@ test.group('Base Model | paginate', (group) => {
})
})
- test('serialize from model paginator', async (assert) => {
+ test('serialize from model paginator', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5643,7 +5667,7 @@ test.group('Base Model | paginate', (group) => {
})
})
- test('return simple paginator instance when using pojo', async (assert) => {
+ test('return simple paginator instance when using pojo', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5684,7 +5708,7 @@ test.group('Base Model | paginate', (group) => {
})
})
- test('use model naming strategy for pagination properties', async (assert) => {
+ test('use model naming strategy for pagination properties', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5738,7 +5762,7 @@ test.group('Base Model | paginate', (group) => {
})
})
- test('use table aliases', async (assert) => {
+ test('use table aliases', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5787,20 +5811,20 @@ test.group('Base Model | paginate', (group) => {
})
test.group('Base Model | toObject', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('convert model to its object representation', async (assert) => {
+ test('convert model to its object representation', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -5812,7 +5836,7 @@ test.group('Base Model | toObject', (group) => {
assert.deepEqual(user.toObject(), { username: 'virk', $extras: {} })
})
- test('use model property key when converting model to object', async (assert) => {
+ test('use model property key when converting model to object', async ({ assert }) => {
class User extends BaseModel {
@column({ serializeAs: 'theUserName', columnName: 'user_name' })
public username: string
@@ -5824,7 +5848,7 @@ test.group('Base Model | toObject', (group) => {
assert.deepEqual(user.toObject(), { username: 'virk', $extras: {} })
})
- test('add computed properties to toObject result', async (assert) => {
+ test('add computed properties to toObject result', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -5841,7 +5865,7 @@ test.group('Base Model | toObject', (group) => {
assert.deepEqual(user.toObject(), { username: 'virk', fullName: 'VIRK', $extras: {} })
})
- test('do not add computed property when it returns undefined', async (assert) => {
+ test('do not add computed property when it returns undefined', async ({ assert }) => {
class User extends BaseModel {
@column()
public username: string
@@ -5858,7 +5882,7 @@ test.group('Base Model | toObject', (group) => {
assert.deepEqual(user.toObject(), { username: 'virk', $extras: {} })
})
- test('add preloaded hasOne relationship to toObject result', async (assert) => {
+ test('add preloaded hasOne relationship to toObject result', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public username: string
@@ -5891,7 +5915,7 @@ test.group('Base Model | toObject', (group) => {
})
})
- test('add preloaded hasMany relationship to toObject result', async (assert) => {
+ test('add preloaded hasMany relationship to toObject result', async ({ assert }) => {
class Comment extends BaseModel {
@column()
public body: string
@@ -5954,20 +5978,20 @@ test.group('Base Model | toObject', (group) => {
})
test.group('Base model | inheritance', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('inherit primary key from the base model', async (assert) => {
+ test('inherit primary key from the base model', async ({ assert }) => {
class MyBaseModel extends BaseModel {
public static primaryKey = 'user_id'
}
@@ -5986,7 +6010,7 @@ test.group('Base model | inheritance', (group) => {
assert.equal(User.primaryKey, 'user_id')
})
- test('use explicitly defined primary key', async (assert) => {
+ test('use explicitly defined primary key', async ({ assert }) => {
class MyBaseModel extends BaseModel {
public static primaryKey = 'user_id'
}
@@ -6007,7 +6031,7 @@ test.group('Base model | inheritance', (group) => {
assert.equal(User.primaryKey, 'the_user_id')
})
- test('do not inherit table from the base model', async (assert) => {
+ test('do not inherit table from the base model', async ({ assert }) => {
class MyBaseModel extends BaseModel {
public static table = 'foo'
}
@@ -6026,7 +6050,7 @@ test.group('Base model | inheritance', (group) => {
assert.equal(User.table, 'users')
})
- test('inherting a model should copy columns', async (assert) => {
+ test('inherting a model should copy columns', async ({ assert }) => {
class MyBaseModel extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6122,7 +6146,7 @@ test.group('Base model | inheritance', (group) => {
})
})
- test('allow overwriting column', async (assert) => {
+ test('allow overwriting column', async ({ assert }) => {
class MyBaseModel extends BaseModel {
@column({ isPrimary: true })
public userId: string
@@ -6221,7 +6245,7 @@ test.group('Base model | inheritance', (group) => {
})
})
- test('inherting a model should copy computed properties', async (assert) => {
+ test('inherting a model should copy computed properties', async ({ assert }) => {
class MyBaseModel extends BaseModel {
@computed()
public fullName: string
@@ -6316,7 +6340,7 @@ test.group('Base model | inheritance', (group) => {
assert.deepEqual(MyBaseModel.$keys.attributesToColumns.all(), {})
})
- test('allow overwriting computed properties', async (assert) => {
+ test('allow overwriting computed properties', async ({ assert }) => {
class MyBaseModel extends BaseModel {
@computed()
public fullName: string
@@ -6404,7 +6428,7 @@ test.group('Base model | inheritance', (group) => {
assert.deepEqual(MyBaseModel.$keys.attributesToColumns.all(), {})
})
- test('inherting a model should copy relationships', async (assert) => {
+ test('inherting a model should copy relationships', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -6439,7 +6463,7 @@ test.group('Base model | inheritance', (group) => {
assert.isFalse(MyBaseModel.$relationsDefinitions.has('emails'))
})
- test('overwrite relationship during relationsip', async (assert) => {
+ test('overwrite relationship during relationsip', async ({ assert }) => {
class SocialProfile extends BaseModel {
@column()
public socialParentId: number
@@ -6488,7 +6512,7 @@ test.group('Base model | inheritance', (group) => {
assert.deepEqual(MyBaseModel.$getRelation('profile').model, MyBaseModel)
})
- test('allow overwriting relationships', async (assert) => {
+ test('allow overwriting relationships', async ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -6531,7 +6555,7 @@ test.group('Base model | inheritance', (group) => {
assert.isUndefined(MyBaseModel.$relationsDefinitions.get('profile')!['onQueryHook'])
})
- test('inherting a model should copy hooks', async (assert) => {
+ test('inherting a model should copy hooks', async ({ assert }) => {
function hook1() {}
function hook2() {}
diff --git a/test/orm/model-belongs-to.spec.ts b/test/orm/model-belongs-to.spec.ts
index 6b3275a4..981f330f 100644
--- a/test/orm/model-belongs-to.spec.ts
+++ b/test/orm/model-belongs-to.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { BelongsTo } from '@ioc:Adonis/Lucid/Orm'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
@@ -32,20 +32,20 @@ let app: ApplicationContract
let BaseModel: ReturnType
test.group('Model | BelongsTo | Options', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('raise error when localKey is missing', (assert) => {
+ test('raise error when localKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -67,7 +67,7 @@ test.group('Model | BelongsTo | Options', (group) => {
}
})
- test('raise error when foreignKey is missing', (assert) => {
+ test('raise error when foreignKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -93,7 +93,7 @@ test.group('Model | BelongsTo | Options', (group) => {
}
})
- test('use primary key is as the local key', (assert) => {
+ test('use primary key is as the local key', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -112,7 +112,7 @@ test.group('Model | BelongsTo | Options', (group) => {
assert.equal(Profile.$getRelation('user')!['localKey'], 'id')
})
- test('use custom defined local key', (assert) => {
+ test('use custom defined local key', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -134,7 +134,7 @@ test.group('Model | BelongsTo | Options', (group) => {
assert.equal(Profile.$getRelation('user')!['localKey'], 'uid')
})
- test('compute foreign key from model name and primary key', (assert) => {
+ test('compute foreign key from model name and primary key', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -153,7 +153,7 @@ test.group('Model | BelongsTo | Options', (group) => {
assert.equal(Profile.$getRelation('user')!['foreignKey'], 'userId')
})
- test('use pre defined foreign key', (assert) => {
+ test('use pre defined foreign key', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -172,7 +172,7 @@ test.group('Model | BelongsTo | Options', (group) => {
assert.equal(Profile.$getRelation('user')!['foreignKey'], 'userUid')
})
- test('clone relationship instance with options', (assert) => {
+ test('clone relationship instance with options', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -198,20 +198,20 @@ test.group('Model | BelongsTo | Options', (group) => {
})
test.group('Model | BelongsTo | Set Relations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set related model instance', (assert) => {
+ test('set related model instance', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -237,7 +237,7 @@ test.group('Model | BelongsTo | Set Relations', (group) => {
assert.deepEqual(profile.user, user)
})
- test('push related model instance', (assert) => {
+ test('push related model instance', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -270,7 +270,7 @@ test.group('Model | BelongsTo | Set Relations', (group) => {
assert.deepEqual(profile.user, user1)
})
- test('set many of related instances', (assert) => {
+ test('set many of related instances', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -309,24 +309,24 @@ test.group('Model | BelongsTo | Set Relations', (group) => {
})
test.group('Model | BelongsTo | bulk operations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sql for selecting related rows', async (assert) => {
+ test('generate correct sql for selecting related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -357,7 +357,7 @@ test.group('Model | BelongsTo | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for selecting many related rows', async (assert) => {
+ test('generate correct sql for selecting many related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -393,7 +393,7 @@ test.group('Model | BelongsTo | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for updating related row', async (assert) => {
+ test('generate correct sql for updating related row', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -430,7 +430,7 @@ test.group('Model | BelongsTo | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for deleting related row', async (assert) => {
+ test('generate correct sql for deleting related row', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -463,24 +463,24 @@ test.group('Model | BelongsTo | bulk operations', (group) => {
})
test.group('Model | BelongsTo | sub queries', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sub query for selecting rows', async (assert) => {
+ test('generate correct sub query for selecting rows', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -518,7 +518,7 @@ test.group('Model | BelongsTo | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('create aggregate query', async (assert) => {
+ test('create aggregate query', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -561,7 +561,7 @@ test.group('Model | BelongsTo | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('allow selecting custom columns', async (assert) => {
+ test('allow selecting custom columns', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -604,7 +604,7 @@ test.group('Model | BelongsTo | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct self relationship subquery', async (assert) => {
+ test('generate correct self relationship subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -639,7 +639,7 @@ test.group('Model | BelongsTo | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('raise exception when trying to execute the query', async (assert) => {
+ test('raise exception when trying to execute the query', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -673,15 +673,15 @@ test.group('Model | BelongsTo | sub queries', (group) => {
const firstOrFail = () =>
Profile.$getRelation('user')!.subQuery(db.connection())['firstOrFail']()
- assert.throw(exec, 'Cannot execute relationship subqueries')
- assert.throw(paginate, 'Cannot execute relationship subqueries')
- assert.throw(update, 'Cannot execute relationship subqueries')
- assert.throw(del, 'Cannot execute relationship subqueries')
- assert.throw(first, 'Cannot execute relationship subqueries')
- assert.throw(firstOrFail, 'Cannot execute relationship subqueries')
+ assert.throws(exec, 'Cannot execute relationship subqueries')
+ assert.throws(paginate, 'Cannot execute relationship subqueries')
+ assert.throws(update, 'Cannot execute relationship subqueries')
+ assert.throws(del, 'Cannot execute relationship subqueries')
+ assert.throws(first, 'Cannot execute relationship subqueries')
+ assert.throws(firstOrFail, 'Cannot execute relationship subqueries')
})
- test('run onQuery method when defined', async (assert) => {
+ test('run onQuery method when defined', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -729,24 +729,24 @@ test.group('Model | BelongsTo | sub queries', (group) => {
})
test.group('Model | BelongsTo | preload', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('preload relationship', async (assert) => {
+ test('preload relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -771,7 +771,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.equal(profiles[0].user.id, profiles[0].userId)
})
- test('set property value to null when no preload rows were found', async (assert) => {
+ test('set property value to null when no preload rows were found', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -795,7 +795,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.isNull(profiles[0].user)
})
- test('set value to null when serializing', async (assert) => {
+ test('set value to null when serializing', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -819,7 +819,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.isNull(profiles[0].toJSON().user)
})
- test('preload relationship for many rows', async (assert) => {
+ test('preload relationship for many rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -856,7 +856,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.equal(profiles[1].user.id, profiles[1].userId)
})
- test('add runtime constraints to related query', async (assert) => {
+ test('add runtime constraints to related query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -895,7 +895,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.isNull(profiles[1].user)
})
- test('cherry pick columns during preload', async (assert) => {
+ test('cherry pick columns during preload', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -938,7 +938,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.deepEqual(profiles[1].user.$extras, {})
})
- test('do not repeat fk when already defined', async (assert) => {
+ test('do not repeat fk when already defined', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -981,7 +981,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.deepEqual(profiles[1].user.$extras, {})
})
- test('raise exception when local key is not selected', async (assert) => {
+ test('raise exception when local key is not selected', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -1030,7 +1030,7 @@ test.group('Model | BelongsTo | preload', (group) => {
}
})
- test('preload using model instance', async (assert) => {
+ test('preload using model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1077,7 +1077,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.equal(profile.user.id, profile.userId)
})
- test('preload nested relations', async (assert) => {
+ test('preload nested relations', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1152,7 +1152,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.instanceOf(identity!.profile!.user, User)
})
- test('preload nested relations using model instance', async (assert) => {
+ test('preload nested relations using model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1227,7 +1227,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.instanceOf(identity!.profile!.user, User)
})
- test('pass main query options down the chain', async (assert) => {
+ test('pass main query options down the chain', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1306,7 +1306,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.equal(identity!.profile.user.$options!.connection, 'secondary')
})
- test('pass relationship metadata to the profiler', async (assert) => {
+ test('pass relationship metadata to the profiler', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -1342,7 +1342,7 @@ test.group('Model | BelongsTo | preload', (group) => {
await Profile.query({ profiler }).preload('user')
})
- test('work fine when foreign key is null', async (assert) => {
+ test('work fine when foreign key is null', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1366,7 +1366,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.isNull(profiles[0].user)
})
- test('work fine during lazy load when foreign key is null', async (assert) => {
+ test('work fine during lazy load when foreign key is null', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1391,7 +1391,7 @@ test.group('Model | BelongsTo | preload', (group) => {
assert.isNull(profiles[0].user)
})
- test('do not run preload query when parent rows are empty', async (assert) => {
+ test('do not run preload query when parent rows are empty', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1415,24 +1415,24 @@ test.group('Model | BelongsTo | preload', (group) => {
})
test.group('Model | BelongsTo | withCount', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get count of a relationship rows', async (assert) => {
+ test('get count of a relationship rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1457,7 +1457,7 @@ test.group('Model | BelongsTo | withCount', (group) => {
assert.equal(profiles[0].$extras.user_count, 1)
})
- test('allow cherry picking columns', async (assert) => {
+ test('allow cherry picking columns', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1485,7 +1485,7 @@ test.group('Model | BelongsTo | withCount', (group) => {
assert.deepEqual(profiles[0].$attributes, { displayName: 'Hvirk' })
})
- test('lazy load relationship row', async (assert) => {
+ test('lazy load relationship row', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1515,24 +1515,24 @@ test.group('Model | BelongsTo | withCount', (group) => {
})
test.group('Model | BelongsTo | has', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1564,24 +1564,24 @@ test.group('Model | BelongsTo | has', (group) => {
})
test.group('Model | BelongsTo | whereHas', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1631,24 +1631,24 @@ test.group('Model | BelongsTo | whereHas', (group) => {
})
test.group('Model | BelongsTo | associate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('associate related instance', async (assert) => {
+ test('associate related instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1684,7 +1684,7 @@ test.group('Model | BelongsTo | associate', (group) => {
assert.equal(profiles[0].user_id, user.id)
})
- test('wrap associate call inside transaction', async (assert) => {
+ test('wrap associate call inside transaction', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -1725,24 +1725,24 @@ test.group('Model | BelongsTo | associate', (group) => {
})
test.group('Model | BelongsTo | dissociate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('dissociate relation', async (assert) => {
+ test('dissociate relation', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1786,24 +1786,24 @@ test.group('Model | BelongsTo | dissociate', (group) => {
})
test.group('Model | BelongsTo | bulk operations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('disallow pagination', async (assert) => {
+ test('disallow pagination', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -1831,24 +1831,24 @@ test.group('Model | BelongsTo | bulk operations', (group) => {
})
test.group('Model | BelongsTo | clone', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('clone related query builder', async (assert) => {
+ test('clone related query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1881,24 +1881,24 @@ test.group('Model | BelongsTo | clone', (group) => {
})
test.group('Model | BelongsTo | scopes', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply scopes during eagerload', async (assert) => {
+ test('apply scopes during eagerload', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1938,7 +1938,7 @@ test.group('Model | BelongsTo | scopes', (group) => {
assert.instanceOf(profileWithoutScope?.user, User)
})
- test('apply scopes on related query', async (assert) => {
+ test('apply scopes on related query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1983,24 +1983,24 @@ test.group('Model | BelongsTo | scopes', (group) => {
})
test.group('Model | BelongsTo | onQuery', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('invoke onQuery method when preloading relationship', async (assert) => {
+ test('invoke onQuery method when preloading relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2033,7 +2033,7 @@ test.group('Model | BelongsTo | onQuery', (group) => {
assert.isNull(profile?.user)
})
- test('do not run onQuery hook on subqueries', async (assert) => {
+ test('do not run onQuery hook on subqueries', async ({ assert }) => {
assert.plan(2)
class User extends BaseModel {
@@ -2074,7 +2074,7 @@ test.group('Model | BelongsTo | onQuery', (group) => {
assert.isNull(profile?.user)
})
- test('invoke onQuery method on related query builder', async (assert) => {
+ test('invoke onQuery method on related query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2107,7 +2107,7 @@ test.group('Model | BelongsTo | onQuery', (group) => {
assert.isNull(user)
})
- test('do not run onQuery hook on related query builder subqueries', async (assert) => {
+ test('do not run onQuery hook on related query builder subqueries', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/orm/model-has-many-through.spec.ts b/test/orm/model-has-many-through.spec.ts
index a2147d24..3834d54f 100644
--- a/test/orm/model-has-many-through.spec.ts
+++ b/test/orm/model-has-many-through.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasManyThrough } from '@ioc:Adonis/Lucid/Orm'
import { scope } from '../../src/Helpers/scope'
@@ -32,20 +32,20 @@ let app: ApplicationContract
let BaseModel: ReturnType
test.group('Model | Has Many Through | Options', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('raise error when localKey is missing', (assert) => {
+ test('raise error when localKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -70,7 +70,7 @@ test.group('Model | Has Many Through | Options', (group) => {
}
})
- test('raise error when foreignKey is missing', (assert) => {
+ test('raise error when foreignKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -98,7 +98,7 @@ test.group('Model | Has Many Through | Options', (group) => {
}
})
- test('raise error when through local key is missing', (assert) => {
+ test('raise error when through local key is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -129,7 +129,7 @@ test.group('Model | Has Many Through | Options', (group) => {
}
})
- test('raise error when through foreign key is missing', (assert) => {
+ test('raise error when through foreign key is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -163,7 +163,7 @@ test.group('Model | Has Many Through | Options', (group) => {
}
})
- test('compute all required keys', (assert) => {
+ test('compute all required keys', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -205,7 +205,7 @@ test.group('Model | Has Many Through | Options', (group) => {
assert.equal(relation['throughForeignKeyColumnName'], 'user_id')
})
- test('compute custom keys', (assert) => {
+ test('compute custom keys', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public uid: number
@@ -252,7 +252,7 @@ test.group('Model | Has Many Through | Options', (group) => {
assert.equal(relation['throughForeignKeyColumnName'], 'user_uid')
})
- test('clone relationship instance with options', (assert) => {
+ test('clone relationship instance with options', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public uid: number
@@ -304,20 +304,20 @@ test.group('Model | Has Many Through | Options', (group) => {
})
test.group('Model | Has Many Through | Set Relations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set related model instance', (assert) => {
+ test('set related model instance', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -351,7 +351,7 @@ test.group('Model | Has Many Through | Set Relations', (group) => {
assert.deepEqual(country.posts, [post])
})
- test('push related model instance', (assert) => {
+ test('push related model instance', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -387,7 +387,7 @@ test.group('Model | Has Many Through | Set Relations', (group) => {
assert.deepEqual(country.posts, [post, post1])
})
- test('set many of related instances', (assert) => {
+ test('set many of related instances', ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -452,24 +452,24 @@ test.group('Model | Has Many Through | Set Relations', (group) => {
})
test.group('Model | Has Many Through | bulk operations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sql for selecting related rows', async (assert) => {
+ test('generate correct sql for selecting related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -512,7 +512,7 @@ test.group('Model | Has Many Through | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for selecting many related rows', async (assert) => {
+ test('generate correct sql for selecting many related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -558,7 +558,7 @@ test.group('Model | Has Many Through | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for updating related rows', async (assert) => {
+ test('generate correct sql for updating related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -610,7 +610,7 @@ test.group('Model | Has Many Through | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for deleting related rows', async (assert) => {
+ test('generate correct sql for deleting related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -656,24 +656,24 @@ test.group('Model | Has Many Through | bulk operations', (group) => {
})
test.group('Model | HasMany | sub queries', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sub query for selecting rows', async (assert) => {
+ test('generate correct sub query for selecting rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -713,7 +713,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('create aggregate query', async (assert) => {
+ test('create aggregate query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -758,7 +758,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('allow selecting custom columns', async (assert) => {
+ test('allow selecting custom columns', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -803,7 +803,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct self relationship subquery', async (assert) => {
+ test('generate correct self relationship subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -848,7 +848,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('raise exception when trying to execute the query', async (assert) => {
+ test('raise exception when trying to execute the query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -883,15 +883,15 @@ test.group('Model | HasMany | sub queries', (group) => {
const firstOrFail = () =>
Country.$getRelation('posts')!.subQuery(db.connection())['firstOrFail']()
- assert.throw(exec, 'Cannot execute relationship subqueries')
- assert.throw(paginate, 'Cannot execute relationship subqueries')
- assert.throw(update, 'Cannot execute relationship subqueries')
- assert.throw(del, 'Cannot execute relationship subqueries')
- assert.throw(first, 'Cannot execute relationship subqueries')
- assert.throw(firstOrFail, 'Cannot execute relationship subqueries')
+ assert.throws(exec, 'Cannot execute relationship subqueries')
+ assert.throws(paginate, 'Cannot execute relationship subqueries')
+ assert.throws(update, 'Cannot execute relationship subqueries')
+ assert.throws(del, 'Cannot execute relationship subqueries')
+ assert.throws(first, 'Cannot execute relationship subqueries')
+ assert.throws(firstOrFail, 'Cannot execute relationship subqueries')
})
- test('run onQuery method when defined', async (assert) => {
+ test('run onQuery method when defined', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -939,24 +939,24 @@ test.group('Model | HasMany | sub queries', (group) => {
})
test.group('Model | Has Many Through | aggregates', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get total of all related rows', async (assert) => {
+ test('get total of all related rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1007,7 +1007,7 @@ test.group('Model | Has Many Through | aggregates', (group) => {
assert.deepEqual(Number(total[0].$extras.total), 2)
})
- test('select extra columns with count', async (assert) => {
+ test('select extra columns with count', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1070,24 +1070,24 @@ test.group('Model | Has Many Through | aggregates', (group) => {
})
test.group('Model | Has Many Through | preload', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('preload through relationships', async (assert) => {
+ test('preload through relationships', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1153,7 +1153,7 @@ test.group('Model | Has Many Through | preload', (group) => {
assert.equal(countries[0].posts[2].$extras.through_country_id, 1)
})
- test('preload many relationships', async (assert) => {
+ test('preload many relationships', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1221,7 +1221,7 @@ test.group('Model | Has Many Through | preload', (group) => {
assert.equal(countries[1].posts[0].$extras.through_country_id, 2)
})
- test('preload many relationships using model instance', async (assert) => {
+ test('preload many relationships using model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1293,7 +1293,7 @@ test.group('Model | Has Many Through | preload', (group) => {
assert.equal(countries[1].posts[0].$extras.through_country_id, 2)
})
- test('cherry pick columns during preload', async (assert) => {
+ test('cherry pick columns during preload', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1364,7 +1364,7 @@ test.group('Model | Has Many Through | preload', (group) => {
assert.deepEqual(countries[1].posts[0].$extras, { through_country_id: 2 })
})
- test('raise error when local key is not selected', async (assert) => {
+ test('raise error when local key is not selected', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1424,7 +1424,7 @@ test.group('Model | Has Many Through | preload', (group) => {
}
})
- test('pass relationship metadata to the profiler', async (assert) => {
+ test('pass relationship metadata to the profiler', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -1497,7 +1497,7 @@ test.group('Model | Has Many Through | preload', (group) => {
await Country.query({ profiler }).preload('posts')
})
- test('do not run preload query when parent rows are empty', async (assert) => {
+ test('do not run preload query when parent rows are empty', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1536,24 +1536,24 @@ test.group('Model | Has Many Through | preload', (group) => {
})
test.group('Model | Has Many Through | withCount', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get count of a relationship rows', async (assert) => {
+ test('get count of a relationship rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1617,7 +1617,7 @@ test.group('Model | Has Many Through | withCount', (group) => {
assert.equal(countries[1].$extras.posts_count, 2)
})
- test('apply constraints to the withCount subquery', async (assert) => {
+ test('apply constraints to the withCount subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1685,7 +1685,7 @@ test.group('Model | Has Many Through | withCount', (group) => {
assert.equal(countries[1].$extras.posts_count, 1)
})
- test('allow subquery to have custom aggregates', async (assert) => {
+ test('allow subquery to have custom aggregates', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1753,7 +1753,7 @@ test.group('Model | Has Many Through | withCount', (group) => {
assert.equal(countries[1].$extras.postsCount, 2)
})
- test('allow cherry picking columns', async (assert) => {
+ test('allow cherry picking columns', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1820,7 +1820,7 @@ test.group('Model | Has Many Through | withCount', (group) => {
assert.deepEqual(countries[1].$attributes, { name: 'Switzerland' })
})
- test('define custom alias for the count', async (assert) => {
+ test('define custom alias for the count', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1892,7 +1892,7 @@ test.group('Model | Has Many Through | withCount', (group) => {
assert.deepEqual(Number(countries[1].$extras.countryPosts), 2)
})
- test('lazy load relationship rows', async (assert) => {
+ test('lazy load relationship rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1953,7 +1953,7 @@ test.group('Model | Has Many Through | withCount', (group) => {
assert.equal(Number(country.$extras.posts_count), 3)
})
- test('apply constraints to the loadCount subquery', async (assert) => {
+ test('apply constraints to the loadCount subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2018,24 +2018,24 @@ test.group('Model | Has Many Through | withCount', (group) => {
})
test.group('Model | Has Many Through | has', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2099,7 +2099,7 @@ test.group('Model | Has Many Through | has', (group) => {
assert.equal(countries[0].name, 'India')
})
- test('define expected number of rows', async (assert) => {
+ test('define expected number of rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2167,24 +2167,24 @@ test.group('Model | Has Many Through | has', (group) => {
})
test.group('Model | Has Many Through | whereHas', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2254,7 +2254,7 @@ test.group('Model | Has Many Through | whereHas', (group) => {
assert.equal(countries[0].name, 'India')
})
- test('define expected number of rows', async (assert) => {
+ test('define expected number of rows', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2332,24 +2332,24 @@ test.group('Model | Has Many Through | whereHas', (group) => {
if (process.env.DB !== 'mysql_legacy') {
test.group('Model | Has Many Through | Group Limit', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply group limit', async (assert) => {
+ test('apply group limit', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2438,7 +2438,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(countries[1].posts[1].$extras.through_country_id, 2)
})
- test('apply group limit with custom constraints', async (assert) => {
+ test('apply group limit with custom constraints', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2529,7 +2529,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(countries[1].posts[1].$extras.through_country_id, 2)
})
- test('apply group limit and cherry pick fields', async (assert) => {
+ test('apply group limit and cherry pick fields', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2627,7 +2627,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(countries[1].posts[1].$extras.through_country_id, 2)
})
- test('apply group limit with custom order', async (assert) => {
+ test('apply group limit with custom order', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2725,7 +2725,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(countries[1].posts[1].$extras.through_country_id, 2)
})
- test('apply standard limit when not eagerloading', async (assert) => {
+ test('apply standard limit when not eagerloading', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2798,7 +2798,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.deepEqual(bindings, knexBindings)
})
- test('apply standard order by when not eagerloading', async (assert) => {
+ test('apply standard order by when not eagerloading', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2881,24 +2881,24 @@ if (process.env.DB !== 'mysql_legacy') {
}
test.group('Model | Has Many Through | pagination', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('paginate using related model query builder instance', async (assert) => {
+ test('paginate using related model query builder instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2986,7 +2986,7 @@ test.group('Model | Has Many Through | pagination', (group) => {
})
})
- test('disallow paginate during preload', async (assert) => {
+ test('disallow paginate during preload', async ({ assert }) => {
assert.plan(1)
class User extends BaseModel {
@@ -3024,24 +3024,24 @@ test.group('Model | Has Many Through | pagination', (group) => {
})
test.group('Model | Has Many Through | clone', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('clone related model query builder', async (assert) => {
+ test('clone related model query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3108,24 +3108,24 @@ test.group('Model | Has Many Through | clone', (group) => {
})
test.group('Model | Has Many Through | scopes', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply scopes during eagerload', async (assert) => {
+ test('apply scopes during eagerload', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3206,7 +3206,7 @@ test.group('Model | Has Many Through | scopes', (group) => {
assert.equal(country.posts[0].title, 'Adonis 101')
})
- test('apply scopes on related query', async (assert) => {
+ test('apply scopes on related query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3287,24 +3287,24 @@ test.group('Model | Has Many Through | scopes', (group) => {
})
test.group('Model | Has Many Through | onQuery', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('invoke onQuery method when preloading relationship', async (assert) => {
+ test('invoke onQuery method when preloading relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3374,7 +3374,7 @@ test.group('Model | Has Many Through | onQuery', (group) => {
assert.equal(country.posts[0].title, 'Adonis 101')
})
- test('do not invoke onQuery method on preloading subqueries', async (assert) => {
+ test('do not invoke onQuery method on preloading subqueries', async ({ assert }) => {
assert.plan(3)
class User extends BaseModel {
@@ -3453,7 +3453,7 @@ test.group('Model | Has Many Through | onQuery', (group) => {
assert.equal(country.posts[0].title, 'Adonis 101')
})
- test('invoke onQuery method on related query builder', async (assert) => {
+ test('invoke onQuery method on related query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3525,7 +3525,7 @@ test.group('Model | Has Many Through | onQuery', (group) => {
assert.equal(posts[0].title, 'Adonis 101')
})
- test('do not invoke onQuery method on related query builder subqueries', async (assert) => {
+ test('do not invoke onQuery method on related query builder subqueries', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/orm/model-has-many.spec.ts b/test/orm/model-has-many.spec.ts
index 4d904e30..314da789 100644
--- a/test/orm/model-has-many.spec.ts
+++ b/test/orm/model-has-many.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasMany } from '@ioc:Adonis/Lucid/Orm'
import { scope } from '../../src/Helpers/scope'
@@ -34,20 +34,20 @@ let app: ApplicationContract
let BaseModel: ReturnType
test.group('Model | HasMany | Options', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('raise error when localKey is missing', (assert) => {
+ test('raise error when localKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -68,7 +68,7 @@ test.group('Model | HasMany | Options', (group) => {
}
})
- test('raise error when foreignKey is missing', (assert) => {
+ test('raise error when foreignKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -93,7 +93,7 @@ test.group('Model | HasMany | Options', (group) => {
}
})
- test('use primary key as the local key', (assert) => {
+ test('use primary key as the local key', ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -113,7 +113,7 @@ test.group('Model | HasMany | Options', (group) => {
assert.equal(User.$getRelation('posts')!['localKey'], 'id')
})
- test('use custom defined primary key', (assert) => {
+ test('use custom defined primary key', ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -136,7 +136,7 @@ test.group('Model | HasMany | Options', (group) => {
assert.equal(User.$getRelation('posts')!['localKey'], 'uid')
})
- test('compute foreign key from model name and primary key', (assert) => {
+ test('compute foreign key from model name and primary key', ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -156,7 +156,7 @@ test.group('Model | HasMany | Options', (group) => {
assert.equal(User.$getRelation('posts')!['foreignKey'], 'userId')
})
- test('use pre defined foreign key', (assert) => {
+ test('use pre defined foreign key', ({ assert }) => {
class Post extends BaseModel {
@column({ columnName: 'user_id' })
public userUid: number
@@ -176,7 +176,7 @@ test.group('Model | HasMany | Options', (group) => {
assert.equal(User.$getRelation('posts')!['foreignKey'], 'userUid')
})
- test('clone relationship instance with options', (assert) => {
+ test('clone relationship instance with options', ({ assert }) => {
class Post extends BaseModel {
@column({ columnName: 'user_id' })
public userUid: number
@@ -201,20 +201,20 @@ test.group('Model | HasMany | Options', (group) => {
})
test.group('Model | HasMany | Set Relations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set related model instance', (assert) => {
+ test('set related model instance', ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -241,7 +241,7 @@ test.group('Model | HasMany | Set Relations', (group) => {
assert.deepEqual(user.posts, [post])
})
- test('push related model instance', (assert) => {
+ test('push related model instance', ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -273,7 +273,7 @@ test.group('Model | HasMany | Set Relations', (group) => {
assert.deepEqual(user.posts, [post, post1])
})
- test('set many of related instances', (assert) => {
+ test('set many of related instances', ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -316,24 +316,24 @@ test.group('Model | HasMany | Set Relations', (group) => {
})
test.group('Model | HasMany | bulk operations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sql for selecting related rows', async (assert) => {
+ test('generate correct sql for selecting related rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -366,7 +366,7 @@ test.group('Model | HasMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for selecting related many rows', async (assert) => {
+ test('generate correct sql for selecting related many rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -401,7 +401,7 @@ test.group('Model | HasMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for updating related rows', async (assert) => {
+ test('generate correct sql for updating related rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -441,7 +441,7 @@ test.group('Model | HasMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for deleting related row', async (assert) => {
+ test('generate correct sql for deleting related row', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -472,7 +472,7 @@ test.group('Model | HasMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql with additional constraints', async (assert) => {
+ test('generate correct sql with additional constraints', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -510,7 +510,7 @@ test.group('Model | HasMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('paginate with additional constraints using related query builder', async (assert) => {
+ test('paginate with additional constraints using related query builder', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -549,24 +549,24 @@ test.group('Model | HasMany | bulk operations', (group) => {
})
test.group('Model | HasMany | sub queries', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sub query for selecting rows', async (assert) => {
+ test('generate correct sub query for selecting rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -598,7 +598,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('create aggregate query', async (assert) => {
+ test('create aggregate query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -635,7 +635,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('allow selecting custom columns', async (assert) => {
+ test('allow selecting custom columns', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -672,7 +672,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct self relationship subquery', async (assert) => {
+ test('generate correct self relationship subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -707,7 +707,7 @@ test.group('Model | HasMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('raise exception when trying to execute the query', async (assert) => {
+ test('raise exception when trying to execute the query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -734,15 +734,15 @@ test.group('Model | HasMany | sub queries', (group) => {
const first = () => User.$getRelation('posts')!.subQuery(db.connection())['first']()
const firstOrFail = () => User.$getRelation('posts')!.subQuery(db.connection())['firstOrFail']()
- assert.throw(exec, 'Cannot execute relationship subqueries')
- assert.throw(paginate, 'Cannot execute relationship subqueries')
- assert.throw(update, 'Cannot execute relationship subqueries')
- assert.throw(del, 'Cannot execute relationship subqueries')
- assert.throw(first, 'Cannot execute relationship subqueries')
- assert.throw(firstOrFail, 'Cannot execute relationship subqueries')
+ assert.throws(exec, 'Cannot execute relationship subqueries')
+ assert.throws(paginate, 'Cannot execute relationship subqueries')
+ assert.throws(update, 'Cannot execute relationship subqueries')
+ assert.throws(del, 'Cannot execute relationship subqueries')
+ assert.throws(first, 'Cannot execute relationship subqueries')
+ assert.throws(firstOrFail, 'Cannot execute relationship subqueries')
})
- test('run onQuery method when defined', async (assert) => {
+ test('run onQuery method when defined', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -784,24 +784,24 @@ test.group('Model | HasMany | sub queries', (group) => {
})
test.group('Model | HasMany | aggregates', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get total of all related rows', async (assert) => {
+ test('get total of all related rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -832,24 +832,24 @@ test.group('Model | HasMany | aggregates', (group) => {
})
test.group('Model | HasMany | preload', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('preload relationship', async (assert) => {
+ test('preload relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -892,7 +892,9 @@ test.group('Model | HasMany | preload', (group) => {
assert.equal(users[1].posts[0].userId, users[1].id)
})
- test('set relationship property value to empty array when no related rows have been found', async (assert) => {
+ test('set relationship property value to empty array when no related rows have been found', async ({
+ assert,
+ }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -920,7 +922,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.lengthOf(users[1].posts, 0)
})
- test('preload relationship for many rows', async (assert) => {
+ test('preload relationship for many rows', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -976,7 +978,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.equal(users[1].posts[0].userId, users[1].id)
})
- test('add constraints during preload', async (assert) => {
+ test('add constraints during preload', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1030,7 +1032,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.lengthOf(users[1].posts, 0)
})
- test('cherry pick columns during preload', async (assert) => {
+ test('cherry pick columns during preload', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1083,7 +1085,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.deepEqual(users[1].posts[0].$extras, {})
})
- test('do not repeat fk when already defined', async (assert) => {
+ test('do not repeat fk when already defined', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1136,7 +1138,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.deepEqual(users[1].posts[0].$extras, {})
})
- test('raise exception when local key is not selected', async (assert) => {
+ test('raise exception when local key is not selected', async ({ assert }) => {
assert.plan(1)
class Post extends BaseModel {
@@ -1187,7 +1189,7 @@ test.group('Model | HasMany | preload', (group) => {
}
})
- test('preload nested relations', async (assert) => {
+ test('preload nested relations', async ({ assert }) => {
class Comment extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1263,7 +1265,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.equal(user!.posts[0].comments[0].postId, user!.posts[0].id)
})
- test('preload nested relations using model instance', async (assert) => {
+ test('preload nested relations using model instance', async ({ assert }) => {
class Comment extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1348,7 +1350,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.equal(users[1].posts[0].comments[0].postId, users[1].posts[0].id)
})
- test('pass main query options down the chain', async (assert) => {
+ test('pass main query options down the chain', async ({ assert }) => {
class Comment extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1428,7 +1430,7 @@ test.group('Model | HasMany | preload', (group) => {
assert.equal(user!.posts[0].comments[0].$options!.connection, 'secondary')
})
- test('pass relationship metadata to the profiler', async (assert) => {
+ test('pass relationship metadata to the profiler', async ({ assert }) => {
assert.plan(1)
class Post extends BaseModel {
@@ -1482,7 +1484,7 @@ test.group('Model | HasMany | preload', (group) => {
await User.query({ profiler }).preload('posts')
})
- test('do not run preload query when parent rows are empty', async (assert) => {
+ test('do not run preload query when parent rows are empty', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1507,24 +1509,24 @@ test.group('Model | HasMany | preload', (group) => {
})
test.group('Model | HasMany | withCount', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get count of a relationship rows', async (assert) => {
+ test('get count of a relationship rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1571,7 +1573,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.posts_count), 1)
})
- test('apply constraints to the withCount subquery', async (assert) => {
+ test('apply constraints to the withCount subquery', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1620,7 +1622,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.posts_count), 1)
})
- test('allow subquery to have custom aggregates', async (assert) => {
+ test('allow subquery to have custom aggregates', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1669,7 +1671,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.postsCount), 1)
})
- test('allow cherry picking columns', async (assert) => {
+ test('allow cherry picking columns', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1722,7 +1724,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.posts_count), 1)
})
- test('get count of self relationship', async (assert) => {
+ test('get count of self relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1775,7 +1777,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.parents_count), 1)
})
- test('define custom alias for the count', async (assert) => {
+ test('define custom alias for the count', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1826,7 +1828,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.totalPosts), 1)
})
- test('get count of a nested relationship', async (assert) => {
+ test('get count of a nested relationship', async ({ assert }) => {
class Comment extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1932,7 +1934,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(posts[1].$extras.comments_count), 1)
})
- test('set count directly on the model when defined as a property', async (assert) => {
+ test('set count directly on the model when defined as a property', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -1981,7 +1983,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].postsCount), 1)
})
- test('do not set count directly on the model when defined as a getter', async (assert) => {
+ test('do not set count directly on the model when defined as a getter', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2034,7 +2036,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.postsCount), 1)
})
- test('lazy load related rows count', async (assert) => {
+ test('lazy load related rows count', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2082,7 +2084,7 @@ test.group('Model | HasMany | withCount', (group) => {
assert.deepEqual(Number(user.$extras.posts_count), 2)
})
- test('apply constraints to the loadCount subquery', async (assert) => {
+ test('apply constraints to the loadCount subquery', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2128,24 +2130,24 @@ test.group('Model | HasMany | withCount', (group) => {
})
test.group('Model | HasMany | has', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2203,7 +2205,7 @@ test.group('Model | HasMany | has', (group) => {
assert.lengthOf(users, 1)
})
- test('define expected number of rows', async (assert) => {
+ test('define expected number of rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2268,7 +2270,7 @@ test.group('Model | HasMany | has', (group) => {
assert.lengthOf(users, 1)
})
- test('merge query existing bindings with the count query', async (assert) => {
+ test('merge query existing bindings with the count query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2334,7 +2336,7 @@ test.group('Model | HasMany | has', (group) => {
assert.lengthOf(users, 1)
})
- test('define or clause in existance query', async (assert) => {
+ test('define or clause in existance query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2400,7 +2402,7 @@ test.group('Model | HasMany | has', (group) => {
assert.lengthOf(users, 2)
})
- test('define not existance query', async (assert) => {
+ test('define not existance query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2463,7 +2465,7 @@ test.group('Model | HasMany | has', (group) => {
assert.equal(users[0].username, 'nikk')
})
- test('define or not existance query', async (assert) => {
+ test('define or not existance query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2536,24 +2538,24 @@ test.group('Model | HasMany | has', (group) => {
})
test.group('Model | HasMany | whereHas', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2621,7 +2623,7 @@ test.group('Model | HasMany | whereHas', (group) => {
assert.lengthOf(users, 1)
})
- test('define expected number of rows', async (assert) => {
+ test('define expected number of rows', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2704,7 +2706,7 @@ test.group('Model | HasMany | whereHas', (group) => {
assert.lengthOf(users, 1)
})
- test('define custom aggregates', async (assert) => {
+ test('define custom aggregates', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2784,7 +2786,7 @@ test.group('Model | HasMany | whereHas', (group) => {
assert.equal(users[0].username, 'nikk')
})
- test('define or clause', async (assert) => {
+ test('define or clause', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2881,7 +2883,7 @@ test.group('Model | HasMany | whereHas', (group) => {
assert.lengthOf(users, 2)
})
- test('define not clause', async (assert) => {
+ test('define not clause', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -2983,7 +2985,7 @@ test.group('Model | HasMany | whereHas', (group) => {
assert.equal(users[0].username, 'nikk')
})
- test('define or not clause', async (assert) => {
+ test('define or not clause', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3088,24 +3090,24 @@ test.group('Model | HasMany | whereHas', (group) => {
if (process.env.DB !== 'mysql_legacy') {
test.group('Model | HasMany | Group Limit', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply group limit', async (assert) => {
+ test('apply group limit', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3218,7 +3220,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.exists(users[1].posts[1].createdAt)
})
- test('apply group limit with additional constraints', async (assert) => {
+ test('apply group limit with additional constraints', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3328,7 +3330,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.exists(users[0].posts[1].createdAt)
})
- test('apply group limit and select custom columns', async (assert) => {
+ test('apply group limit and select custom columns', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3429,7 +3431,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.isUndefined(users[1].posts[1].createdAt)
})
- test('define custom order by clause', async (assert) => {
+ test('define custom order by clause', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3544,7 +3546,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.exists(users[1].posts[1].createdAt)
})
- test('apply standard limit when not eagerloading', async (assert) => {
+ test('apply standard limit when not eagerloading', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3619,7 +3621,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.deepEqual(bindings, knexBindings)
})
- test('apply standard order by when not eagerloading', async (assert) => {
+ test('apply standard order by when not eagerloading', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -3700,7 +3702,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.deepEqual(bindings, knexBindings)
})
- test('preload with group limit', async (assert) => {
+ test('preload with group limit', async ({ assert }) => {
class Comment extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3832,7 +3834,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.lengthOf(users[1].posts[1].comments, 2)
})
- test('pass sideloaded data after applying group limit', async (assert) => {
+ test('pass sideloaded data after applying group limit', async ({ assert }) => {
class Comment extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3971,24 +3973,24 @@ if (process.env.DB !== 'mysql_legacy') {
}
test.group('Model | HasMany | save', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('save related instance', async (assert) => {
+ test('save related instance', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4032,24 +4034,24 @@ test.group('Model | HasMany | save', (group) => {
})
test.group('Model | HasMany | saveMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('save many related instances', async (assert) => {
+ test('save many related instances', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4097,7 +4099,7 @@ test.group('Model | HasMany | saveMany', (group) => {
assert.equal(totalPosts[0].total, 2)
})
- test('wrap save many calls inside transaction', async (assert) => {
+ test('wrap save many calls inside transaction', async ({ assert }) => {
assert.plan(6)
class Post extends BaseModel {
@@ -4146,7 +4148,7 @@ test.group('Model | HasMany | saveMany', (group) => {
assert.isUndefined(post1.$trx)
})
- test('use parent model transaction when exists', async (assert) => {
+ test('use parent model transaction when exists', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4197,24 +4199,24 @@ test.group('Model | HasMany | saveMany', (group) => {
})
test.group('Model | HasMany | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create related instance', async (assert) => {
+ test('create related instance', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4255,24 +4257,24 @@ test.group('Model | HasMany | create', (group) => {
})
test.group('Model | HasMany | createMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create many related instances', async (assert) => {
+ test('create many related instances', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4321,7 +4323,7 @@ test.group('Model | HasMany | createMany', (group) => {
assert.equal(totalPosts[0].total, 2)
})
- test('wrap create many calls inside transaction', async (assert) => {
+ test('wrap create many calls inside transaction', async ({ assert }) => {
assert.plan(4)
class Post extends BaseModel {
@@ -4363,7 +4365,7 @@ test.group('Model | HasMany | createMany', (group) => {
assert.isUndefined(user.$trx)
})
- test('use parent model transaction when already exists', async (assert) => {
+ test('use parent model transaction when already exists', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4406,24 +4408,24 @@ test.group('Model | HasMany | createMany', (group) => {
})
test.group('Model | HasMany | firstOrCreate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("create related instance when there isn't any existing row", async (assert) => {
+ test("create related instance when there isn't any existing row", async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4468,7 +4470,7 @@ test.group('Model | HasMany | firstOrCreate', (group) => {
assert.equal(posts[1].user_id, user.id)
})
- test('return existing instance vs creating one', async (assert) => {
+ test('return existing instance vs creating one', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4515,24 +4517,24 @@ test.group('Model | HasMany | firstOrCreate', (group) => {
})
test.group('Model | HasMany | updateOrCreate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("create related instance when there isn't any existing row", async (assert) => {
+ test("create related instance when there isn't any existing row", async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4577,7 +4579,7 @@ test.group('Model | HasMany | updateOrCreate', (group) => {
assert.equal(posts[1].user_id, user.id)
})
- test('update existing instance vs creating one', async (assert) => {
+ test('update existing instance vs creating one', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4625,24 +4627,24 @@ test.group('Model | HasMany | updateOrCreate', (group) => {
})
test.group('Model | HasMany | fetchOrCreateMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("create related instance when there aren't any existing row", async (assert) => {
+ test("create related instance when there aren't any existing row", async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4687,7 +4689,7 @@ test.group('Model | HasMany | fetchOrCreateMany', (group) => {
assert.equal(posts[1].user_id, user.id)
})
- test('return existing instance vs creating one', async (assert) => {
+ test('return existing instance vs creating one', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4753,24 +4755,24 @@ test.group('Model | HasMany | fetchOrCreateMany', (group) => {
})
test.group('Model | HasMany | fetchOrCreateMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("create related instance when there aren't any existing row", async (assert) => {
+ test("create related instance when there aren't any existing row", async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4815,7 +4817,7 @@ test.group('Model | HasMany | fetchOrCreateMany', (group) => {
assert.equal(posts[1].user_id, user.id)
})
- test('update existing instance vs creating one', async (assert) => {
+ test('update existing instance vs creating one', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4893,24 +4895,24 @@ test.group('Model | HasMany | fetchOrCreateMany', (group) => {
})
test.group('Model | HasMany | paginate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('paginate using related model query builder instance', async (assert) => {
+ test('paginate using related model query builder instance', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -4961,7 +4963,7 @@ test.group('Model | HasMany | paginate', (group) => {
})
})
- test('disallow paginate during preload', async (assert) => {
+ test('disallow paginate during preload', async ({ assert }) => {
assert.plan(1)
class Post extends BaseModel {
@@ -4993,24 +4995,24 @@ test.group('Model | HasMany | paginate', (group) => {
})
test.group('Model | HasMany | clone', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('clone related model query builder', async (assert) => {
+ test('clone related model query builder', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -5036,24 +5038,24 @@ test.group('Model | HasMany | clone', (group) => {
})
test.group('Model | HasMany | scopes', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply scopes during eagerload', async (assert) => {
+ test('apply scopes during eagerload', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -5104,7 +5106,7 @@ test.group('Model | HasMany | scopes', (group) => {
assert.equal(user.posts[0].title, 'Adonis 101')
})
- test('apply scopes on related query', async (assert) => {
+ test('apply scopes on related query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -5157,24 +5159,24 @@ test.group('Model | HasMany | scopes', (group) => {
})
test.group('Model | HasMany | onQuery', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('invoke onQuery method when preloading relationship', async (assert) => {
+ test('invoke onQuery method when preloading relationship', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -5215,7 +5217,7 @@ test.group('Model | HasMany | onQuery', (group) => {
assert.equal(user.posts[0].title, 'Adonis 101')
})
- test('do not invoke onQuery method on preloading subqueries', async (assert) => {
+ test('do not invoke onQuery method on preloading subqueries', async ({ assert }) => {
assert.plan(3)
class Post extends BaseModel {
@@ -5262,7 +5264,7 @@ test.group('Model | HasMany | onQuery', (group) => {
assert.equal(user.posts[0].title, 'Adonis 101')
})
- test('invoke onQuery method on related query', async (assert) => {
+ test('invoke onQuery method on related query', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -5304,7 +5306,7 @@ test.group('Model | HasMany | onQuery', (group) => {
assert.equal(posts[0].title, 'Adonis 101')
})
- test('do not invoke onQuery method on related query subqueries', async (assert) => {
+ test('do not invoke onQuery method on related query subqueries', async ({ assert }) => {
class Post extends BaseModel {
@column()
public userId: number
@@ -5366,24 +5368,24 @@ test.group('Model | HasMany | onQuery', (group) => {
})
test.group('Model | HasMany | delete', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('delete related instance', async (assert) => {
+ test('delete related instance', async ({ assert }) => {
class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/orm/model-has-one.spec.ts b/test/orm/model-has-one.spec.ts
index dc7c2e99..4e4c639e 100644
--- a/test/orm/model-has-one.spec.ts
+++ b/test/orm/model-has-one.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { HasOne, BelongsTo } from '@ioc:Adonis/Lucid/Orm'
import { scope } from '../../src/Helpers/scope'
@@ -32,20 +32,20 @@ let app: ApplicationContract
let BaseModel: ReturnType
test.group('Model | HasOne | Options', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('raise error when localKey is missing', (assert) => {
+ test('raise error when localKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -66,7 +66,7 @@ test.group('Model | HasOne | Options', (group) => {
}
})
- test('raise error when foreignKey is missing', (assert) => {
+ test('raise error when foreignKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -91,7 +91,7 @@ test.group('Model | HasOne | Options', (group) => {
}
})
- test('use primary key is as the local key', (assert) => {
+ test('use primary key is as the local key', ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -112,7 +112,7 @@ test.group('Model | HasOne | Options', (group) => {
assert.equal(User.$getRelation('profile')!['localKey'], 'id')
})
- test('use custom defined local key', (assert) => {
+ test('use custom defined local key', ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -136,7 +136,7 @@ test.group('Model | HasOne | Options', (group) => {
assert.equal(User.$getRelation('profile')!['localKey'], 'uid')
})
- test('compute foreign key from model name and primary key', (assert) => {
+ test('compute foreign key from model name and primary key', ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -157,7 +157,7 @@ test.group('Model | HasOne | Options', (group) => {
assert.equal(User.$getRelation('profile')!['foreignKey'], 'userId')
})
- test('use pre defined foreign key', (assert) => {
+ test('use pre defined foreign key', ({ assert }) => {
class Profile extends BaseModel {
@column({ columnName: 'user_id' })
public userUid: number
@@ -178,7 +178,7 @@ test.group('Model | HasOne | Options', (group) => {
assert.equal(User.$getRelation('profile')!['foreignKey'], 'userUid')
})
- test('clone relationship instance with options', (assert) => {
+ test('clone relationship instance with options', ({ assert }) => {
class Profile extends BaseModel {
@column({ columnName: 'user_id' })
public userUid: number
@@ -204,20 +204,20 @@ test.group('Model | HasOne | Options', (group) => {
})
test.group('Model | HasOne | Set Relations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set related model instance', (assert) => {
+ test('set related model instance', ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -240,7 +240,7 @@ test.group('Model | HasOne | Set Relations', (group) => {
assert.deepEqual(user.profile, profile)
})
- test('push related model instance', (assert) => {
+ test('push related model instance', ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -263,7 +263,7 @@ test.group('Model | HasOne | Set Relations', (group) => {
assert.deepEqual(user.profile, profile)
})
- test('set many of related instances', (assert) => {
+ test('set many of related instances', ({ assert }) => {
class Profile extends BaseModel {
@column()
public userId: number
@@ -303,24 +303,24 @@ test.group('Model | HasOne | Set Relations', (group) => {
})
test.group('Model | HasOne | bulk operations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sql for selecting related rows', async (assert) => {
+ test('generate correct sql for selecting related rows', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -360,7 +360,7 @@ test.group('Model | HasOne | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for selecting related many rows', async (assert) => {
+ test('generate correct sql for selecting related many rows', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -402,7 +402,7 @@ test.group('Model | HasOne | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for updating related row', async (assert) => {
+ test('generate correct sql for updating related row', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -448,7 +448,7 @@ test.group('Model | HasOne | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for deleting related row', async (assert) => {
+ test('generate correct sql for deleting related row', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -490,24 +490,24 @@ test.group('Model | HasOne | bulk operations', (group) => {
})
test.group('Model | HasOne | sub queries', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct subquery for selecting rows', async (assert) => {
+ test('generate correct subquery for selecting rows', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -545,7 +545,7 @@ test.group('Model | HasOne | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('create aggregate query', async (assert) => {
+ test('create aggregate query', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -588,7 +588,7 @@ test.group('Model | HasOne | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('allow selecting custom columns', async (assert) => {
+ test('allow selecting custom columns', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -631,7 +631,7 @@ test.group('Model | HasOne | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct self relationship subquery', async (assert) => {
+ test('generate correct self relationship subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -666,7 +666,7 @@ test.group('Model | HasOne | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('raise exception when trying to execute the query', async (assert) => {
+ test('raise exception when trying to execute the query', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -700,15 +700,15 @@ test.group('Model | HasOne | sub queries', (group) => {
const firstOrFail = () =>
User.$getRelation('profile')!.subQuery(db.connection())['firstOrFail']()
- assert.throw(exec, 'Cannot execute relationship subqueries')
- assert.throw(paginate, 'Cannot execute relationship subqueries')
- assert.throw(update, 'Cannot execute relationship subqueries')
- assert.throw(del, 'Cannot execute relationship subqueries')
- assert.throw(first, 'Cannot execute relationship subqueries')
- assert.throw(firstOrFail, 'Cannot execute relationship subqueries')
+ assert.throws(exec, 'Cannot execute relationship subqueries')
+ assert.throws(paginate, 'Cannot execute relationship subqueries')
+ assert.throws(update, 'Cannot execute relationship subqueries')
+ assert.throws(del, 'Cannot execute relationship subqueries')
+ assert.throws(first, 'Cannot execute relationship subqueries')
+ assert.throws(firstOrFail, 'Cannot execute relationship subqueries')
})
- test('run onQuery method when defined', async (assert) => {
+ test('run onQuery method when defined', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -756,24 +756,24 @@ test.group('Model | HasOne | sub queries', (group) => {
})
test.group('Model | HasOne | preload', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('preload relationship', async (assert) => {
+ test('preload relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -822,7 +822,9 @@ test.group('Model | HasOne | preload', (group) => {
assert.equal(users[1].profile.userId, users[1].id)
})
- test('set relationship property value to null when no related rows were found', async (assert) => {
+ test('set relationship property value to null when no related rows were found', async ({
+ assert,
+ }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -856,7 +858,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.isNull(users[1].profile)
})
- test('preload nested relations', async (assert) => {
+ test('preload nested relations', async ({ assert }) => {
class Identity extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -933,7 +935,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.instanceOf(user!.profile!.identity, Identity)
})
- test('preload self referenced relationship', async (assert) => {
+ test('preload self referenced relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -985,7 +987,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.deepEqual(users[1].profile.user.id, users[1].id)
})
- test('add constraints during preload', async (assert) => {
+ test('add constraints during preload', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1036,7 +1038,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.isNull(users[1].profile)
})
- test('cherry pick columns during preload', async (assert) => {
+ test('cherry pick columns during preload', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1087,7 +1089,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.deepEqual(users[1].profile.$extras, {})
})
- test('do not repeat fk when already defined', async (assert) => {
+ test('do not repeat fk when already defined', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1138,7 +1140,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.deepEqual(users[1].profile.$extras, {})
})
- test('pass sideloaded attributes to the relationship', async (assert) => {
+ test('pass sideloaded attributes to the relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1189,7 +1191,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.deepEqual(users[1].profile.$sideloaded, { id: 1 })
})
- test('preload using model instance', async (assert) => {
+ test('preload using model instance', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1239,7 +1241,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.equal(users[1].profile.userId, users[1].id)
})
- test('raise exception when local key is not selected', async (assert) => {
+ test('raise exception when local key is not selected', async ({ assert }) => {
assert.plan(1)
class Profile extends BaseModel {
@@ -1288,7 +1290,7 @@ test.group('Model | HasOne | preload', (group) => {
}
})
- test('preload nested relations using model instance', async (assert) => {
+ test('preload nested relations using model instance', async ({ assert }) => {
class Identity extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1374,7 +1376,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.instanceOf(users[1].profile!.identity, Identity)
})
- test('pass main query options down the chain', async (assert) => {
+ test('pass main query options down the chain', async ({ assert }) => {
class Identity extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1455,7 +1457,7 @@ test.group('Model | HasOne | preload', (group) => {
assert.equal(user!.profile.identity.$options!.connection, 'secondary')
})
- test('pass relationship metadata to the profiler', async (assert) => {
+ test('pass relationship metadata to the profiler', async ({ assert }) => {
assert.plan(1)
class Profile extends BaseModel {
@@ -1515,7 +1517,7 @@ test.group('Model | HasOne | preload', (group) => {
await User.query({ profiler }).preload('profile')
})
- test('do not run preload query when parent rows are empty', async (assert) => {
+ test('do not run preload query when parent rows are empty', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1546,24 +1548,24 @@ test.group('Model | HasOne | preload', (group) => {
})
test.group('Model | HasOne | withCount', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get count of a relationship rows', async (assert) => {
+ test('get count of a relationship rows', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1612,7 +1614,7 @@ test.group('Model | HasOne | withCount', (group) => {
assert.equal(users[1].$extras.profile_count, 1)
})
- test('allow cherry picking columns', async (assert) => {
+ test('allow cherry picking columns', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1664,7 +1666,7 @@ test.group('Model | HasOne | withCount', (group) => {
assert.deepEqual(users[1].$attributes, { username: 'nikk' })
})
- test('lazy load related count', async (assert) => {
+ test('lazy load related count', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1712,7 +1714,7 @@ test.group('Model | HasOne | withCount', (group) => {
assert.deepEqual(Number(user.$extras.profile_count), 1)
})
- test('lazy load count of self referenced relationship', async (assert) => {
+ test('lazy load count of self referenced relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1739,24 +1741,24 @@ test.group('Model | HasOne | withCount', (group) => {
})
test.group('Model | HasOne | has', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1805,24 +1807,24 @@ test.group('Model | HasOne | has', (group) => {
})
test.group('Model | HasOne | whereHas', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1884,24 +1886,24 @@ test.group('Model | HasOne | whereHas', (group) => {
})
test.group('Model | HasOne | save', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('save related instance', async (assert) => {
+ test('save related instance', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1937,7 +1939,7 @@ test.group('Model | HasOne | save', (group) => {
assert.equal(user.id, profile.userId)
})
- test('wrap save calls inside a managed transaction', async (assert) => {
+ test('wrap save calls inside a managed transaction', async ({ assert }) => {
assert.plan(3)
class Profile extends BaseModel {
@@ -1979,7 +1981,7 @@ test.group('Model | HasOne | save', (group) => {
assert.lengthOf(profiles, 0)
})
- test('use parent model transaction when its defined', async (assert) => {
+ test('use parent model transaction when its defined', async ({ assert }) => {
assert.plan(4)
class Profile extends BaseModel {
@@ -2028,24 +2030,24 @@ test.group('Model | HasOne | save', (group) => {
})
test.group('Model | HasOne | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create related instance', async (assert) => {
+ test('create related instance', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2080,7 +2082,7 @@ test.group('Model | HasOne | create', (group) => {
assert.equal(user.id, profile.userId)
})
- test('wrap create call inside a managed transaction', async (assert) => {
+ test('wrap create call inside a managed transaction', async ({ assert }) => {
assert.plan(3)
class Profile extends BaseModel {
@@ -2121,7 +2123,7 @@ test.group('Model | HasOne | create', (group) => {
assert.lengthOf(profiles, 0)
})
- test('use parent model transaction during create', async (assert) => {
+ test('use parent model transaction during create', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2166,24 +2168,24 @@ test.group('Model | HasOne | create', (group) => {
})
test.group('Model | HasOne | firstOrCreate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("create related instance when there isn't any existing row", async (assert) => {
+ test("create related instance when there isn't any existing row", async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2223,7 +2225,7 @@ test.group('Model | HasOne | firstOrCreate', (group) => {
assert.equal(profile.displayName, 'Hvirk')
})
- test('return the existing row vs creating a new one', async (assert) => {
+ test('return the existing row vs creating a new one', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2269,24 +2271,24 @@ test.group('Model | HasOne | firstOrCreate', (group) => {
})
test.group('Model | HasOne | updateOrCreate', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("create related instance when there isn't any existing row", async (assert) => {
+ test("create related instance when there isn't any existing row", async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2330,7 +2332,7 @@ test.group('Model | HasOne | updateOrCreate', (group) => {
assert.equal(profiles[0].display_name, 'Virk')
})
- test('update the existing row vs creating a new one', async (assert) => {
+ test('update the existing row vs creating a new one', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2377,24 +2379,24 @@ test.group('Model | HasOne | updateOrCreate', (group) => {
})
test.group('Model | HasOne | pagination', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('dis-allow pagination', async (assert) => {
+ test('dis-allow pagination', async ({ assert }) => {
assert.plan(1)
class Profile extends BaseModel {
@@ -2431,24 +2433,24 @@ test.group('Model | HasOne | pagination', (group) => {
})
test.group('Model | HasOne | clone', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('clone related query builder', async (assert) => {
+ test('clone related query builder', async ({ assert }) => {
assert.plan(1)
class Profile extends BaseModel {
@@ -2482,24 +2484,24 @@ test.group('Model | HasOne | clone', (group) => {
})
test.group('Model | HasOne | scopes', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply scopes during eagerload', async (assert) => {
+ test('apply scopes during eagerload', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2547,7 +2549,7 @@ test.group('Model | HasOne | scopes', (group) => {
assert.instanceOf(userWithScopes.profile, Profile)
})
- test('apply scopes on related query', async (assert) => {
+ test('apply scopes on related query', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2599,24 +2601,24 @@ test.group('Model | HasOne | scopes', (group) => {
})
test.group('Model | HasOne | onQuery', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('invoke onQuery method when preloading relationship', async (assert) => {
+ test('invoke onQuery method when preloading relationship', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2655,7 +2657,7 @@ test.group('Model | HasOne | onQuery', (group) => {
assert.isNull(user.profile)
})
- test('do not invoke onQuery method on preloading subqueries', async (assert) => {
+ test('do not invoke onQuery method on preloading subqueries', async ({ assert }) => {
assert.plan(2)
class Profile extends BaseModel {
@@ -2701,7 +2703,7 @@ test.group('Model | HasOne | onQuery', (group) => {
assert.isNull(user.profile)
})
- test('invoke onQuery method on related query builder', async (assert) => {
+ test('invoke onQuery method on related query builder', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2741,7 +2743,7 @@ test.group('Model | HasOne | onQuery', (group) => {
assert.isNull(profile)
})
- test('do not invoke onQuery method on related query builder subqueries', async (assert) => {
+ test('do not invoke onQuery method on related query builder subqueries', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2803,24 +2805,24 @@ test.group('Model | HasOne | onQuery', (group) => {
})
test.group('Model | HasOne | delete', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('delete related instance', async (assert) => {
+ test('delete related instance', async ({ assert }) => {
class Profile extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/orm/model-many-to-many.spec.ts b/test/orm/model-many-to-many.spec.ts
index 334303ee..20231587 100644
--- a/test/orm/model-many-to-many.spec.ts
+++ b/test/orm/model-many-to-many.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import type { ManyToMany } from '@ioc:Adonis/Lucid/Orm'
import { scope } from '../../src/Helpers/scope'
@@ -35,20 +35,20 @@ let BaseModel: ReturnType
const sleep = (time: number) => new Promise((resolve) => setTimeout(resolve, time))
test.group('Model | ManyToMany | Options', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('raise error when localKey is missing', (assert) => {
+ test('raise error when localKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -69,7 +69,7 @@ test.group('Model | ManyToMany | Options', (group) => {
}
})
- test('use primary key as the local key', (assert) => {
+ test('use primary key as the local key', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -89,7 +89,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['localKeyColumnName'], 'id')
})
- test('use custom defined local key', (assert) => {
+ test('use custom defined local key', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -113,7 +113,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['localKeyColumnName'], 'uid')
})
- test('raise error when relatedKey is missing', (assert) => {
+ test('raise error when relatedKey is missing', ({ assert }) => {
assert.plan(1)
try {
@@ -138,7 +138,7 @@ test.group('Model | ManyToMany | Options', (group) => {
}
})
- test('use related model primary key as the related key', (assert) => {
+ test('use related model primary key as the related key', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -158,7 +158,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['relatedKeyColumnName'], 'id')
})
- test('use custom defined related key', (assert) => {
+ test('use custom defined related key', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -181,7 +181,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['relatedKeyColumnName'], 'uid')
})
- test('compute pivotForeignKey from table name + primary key', (assert) => {
+ test('compute pivotForeignKey from table name + primary key', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -200,7 +200,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['pivotForeignKey'], 'user_id')
})
- test('use custom defined pivotForeignKey', (assert) => {
+ test('use custom defined pivotForeignKey', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -219,7 +219,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['pivotForeignKey'], 'user_uid')
})
- test('compute relatedPivotForeignKey from related model name + primary key', (assert) => {
+ test('compute relatedPivotForeignKey from related model name + primary key', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -239,7 +239,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['pivotRelatedForeignKey'], 'skill_id')
})
- test('use custom defined relatedPivotForeignKey', (assert) => {
+ test('use custom defined relatedPivotForeignKey', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -259,7 +259,7 @@ test.group('Model | ManyToMany | Options', (group) => {
assert.equal(User.$getRelation('skills')!['pivotRelatedForeignKey'], 'skill_uid')
})
- test('clone relationship instance with options', (assert) => {
+ test('clone relationship instance with options', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -283,20 +283,20 @@ test.group('Model | ManyToMany | Options', (group) => {
})
test.group('Model | ManyToMany | Set Relations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('set related model instance', (assert) => {
+ test('set related model instance', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -318,7 +318,7 @@ test.group('Model | ManyToMany | Set Relations', (group) => {
assert.deepEqual(user.skills, [skill])
})
- test('push related model instance', (assert) => {
+ test('push related model instance', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -343,7 +343,7 @@ test.group('Model | ManyToMany | Set Relations', (group) => {
assert.deepEqual(user.skills, [skill, skill1])
})
- test('set many of related instances', (assert) => {
+ test('set many of related instances', ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -395,24 +395,24 @@ test.group('Model | ManyToMany | Set Relations', (group) => {
})
test.group('Model | ManyToMany | bulk operations', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sql for selecting related rows', async (assert) => {
+ test('generate correct sql for selecting related rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -448,7 +448,7 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for selecting related for many rows', async (assert) => {
+ test('generate correct sql for selecting related for many rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -487,7 +487,7 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('select extra columns', async (assert) => {
+ test('select extra columns', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -526,7 +526,7 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('select extra columns at runtime', async (assert) => {
+ test('select extra columns at runtime', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -563,7 +563,7 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for updating rows', async (assert) => {
+ test('generate correct sql for updating rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -596,7 +596,7 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct sql for deleting rows', async (assert) => {
+ test('generate correct sql for deleting rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -627,7 +627,7 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('convert timestamps instance of Luxon', async (assert) => {
+ test('convert timestamps instance of Luxon', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -679,24 +679,24 @@ test.group('Model | ManyToMany | bulk operations', (group) => {
})
test.group('Model | ManyToMany | sub queries', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('generate correct sub query for selecting rows', async (assert) => {
+ test('generate correct sub query for selecting rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -726,7 +726,7 @@ test.group('Model | ManyToMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('create aggregate query', async (assert) => {
+ test('create aggregate query', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -761,7 +761,7 @@ test.group('Model | ManyToMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('allow selecting custom columns', async (assert) => {
+ test('allow selecting custom columns', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -796,7 +796,7 @@ test.group('Model | ManyToMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('generate correct self relationship subquery', async (assert) => {
+ test('generate correct self relationship subquery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -826,7 +826,7 @@ test.group('Model | ManyToMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where pivot clause when self relationship subQuery', async (assert) => {
+ test('add where pivot clause when self relationship subQuery', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -864,7 +864,7 @@ test.group('Model | ManyToMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('allow selecting custom pivot columns', async (assert) => {
+ test('allow selecting custom pivot columns', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -899,7 +899,7 @@ test.group('Model | ManyToMany | sub queries', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('run onQuery method when defined', async (assert) => {
+ test('run onQuery method when defined', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -939,24 +939,24 @@ test.group('Model | ManyToMany | sub queries', (group) => {
})
test.group('Model | Many To Many | aggregates', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get total of all related rows', async (assert) => {
+ test('get total of all related rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -986,7 +986,7 @@ test.group('Model | Many To Many | aggregates', (group) => {
assert.deepEqual(Number(total[0].$extras.total), 2)
})
- test('select extra columns with count', async (assert) => {
+ test('select extra columns with count', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1027,7 +1027,7 @@ test.group('Model | Many To Many | aggregates', (group) => {
assert.equal(Number(total[1].$extras.total), 1)
})
- test('select extra pivot columns with count', async (assert) => {
+ test('select extra pivot columns with count', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1071,24 +1071,24 @@ test.group('Model | Many To Many | aggregates', (group) => {
})
test.group('Model | ManyToMany | preload', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('preload relation', async (assert) => {
+ test('preload relation', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1132,7 +1132,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.equal(users[0].skills[0].$extras.pivot_skill_id, 1)
})
- test('convert dates to luxon datetime instance during preload', async (assert) => {
+ test('convert dates to luxon datetime instance during preload', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1182,7 +1182,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.instanceOf(users[0].skills[0].$extras.pivot_updated_at, DateTime)
})
- test('preload relation for many', async (assert) => {
+ test('preload relation for many', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1245,7 +1245,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.equal(users[1].skills[0].$extras.pivot_skill_id, 2)
})
- test('preload relation using model instance', async (assert) => {
+ test('preload relation using model instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1312,7 +1312,9 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.equal(users[1].skills[0].$extras.pivot_skill_id, 2)
})
- test('convert dates to luxon datetime instance when preload using model instance', async (assert) => {
+ test('convert dates to luxon datetime instance when preload using model instance', async ({
+ assert,
+ }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1364,7 +1366,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.instanceOf(users[0].skills[0].$extras.pivot_updated_at, DateTime)
})
- test('select extra pivot columns', async (assert) => {
+ test('select extra pivot columns', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1436,7 +1438,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.equal(users[1].skills[0].$extras.pivot_proficiency, 'beginner')
})
- test('select extra pivot columns at runtime', async (assert) => {
+ test('select extra pivot columns at runtime', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1511,7 +1513,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.equal(users[1].skills[0].$extras.pivot_proficiency, 'beginner')
})
- test('cherry pick columns during preload', async (assert) => {
+ test('cherry pick columns during preload', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1557,7 +1559,7 @@ test.group('Model | ManyToMany | preload', (group) => {
assert.deepEqual(users[0].skills[0].$extras, { pivot_user_id: 1, pivot_skill_id: 1 })
})
- test('raise error when local key is not selected', async (assert) => {
+ test('raise error when local key is not selected', async ({ assert }) => {
assert.plan(1)
class Skill extends BaseModel {
@@ -1611,7 +1613,7 @@ test.group('Model | ManyToMany | preload', (group) => {
}
})
- test('do not run preload query when parent rows are empty', async (assert) => {
+ test('do not run preload query when parent rows are empty', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1638,24 +1640,24 @@ test.group('Model | ManyToMany | preload', (group) => {
})
test.group('Model | ManyToMany | withCount', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get count of a relationship rows', async (assert) => {
+ test('get count of a relationship rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1708,7 +1710,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.skills_count), 1)
})
- test('apply constraints to the withCount subquery', async (assert) => {
+ test('apply constraints to the withCount subquery', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1765,7 +1767,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.skills_count), 0)
})
- test('allow subquery to have custom aggregates', async (assert) => {
+ test('allow subquery to have custom aggregates', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1822,7 +1824,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.skillsCount), 1)
})
- test('allow cherry picking columns', async (assert) => {
+ test('allow cherry picking columns', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1878,7 +1880,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(users[1].$attributes, { username: 'nikk' })
})
- test('get count of self relationship', async (assert) => {
+ test('get count of self relationship', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1930,7 +1932,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(users[3].$extras.follows_count), 0)
})
- test('define custom alias for the count', async (assert) => {
+ test('define custom alias for the count', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -1991,7 +1993,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.mySkills), 1)
})
- test('get count of a nested relationship rows', async (assert) => {
+ test('get count of a nested relationship rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2100,7 +2102,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(users[1].$extras.skills_count), 1)
})
- test('lazy load count of relationship rows', async (assert) => {
+ test('lazy load count of relationship rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2148,7 +2150,7 @@ test.group('Model | ManyToMany | withCount', (group) => {
assert.deepEqual(Number(user.$extras.skills_count), 2)
})
- test('apply constraints to the loadCount subquery', async (assert) => {
+ test('apply constraints to the loadCount subquery', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2200,24 +2202,24 @@ test.group('Model | ManyToMany | withCount', (group) => {
})
test.group('Model | ManyToMany | has', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2267,7 +2269,7 @@ test.group('Model | ManyToMany | has', (group) => {
assert.deepEqual(users[0].username, 'virk')
})
- test('define expected number of rows', async (assert) => {
+ test('define expected number of rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2323,24 +2325,24 @@ test.group('Model | ManyToMany | has', (group) => {
})
test.group('Model | ManyToMany | whereHas', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('limit rows to the existance of relationship', async (assert) => {
+ test('limit rows to the existance of relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2402,7 +2404,7 @@ test.group('Model | ManyToMany | whereHas', (group) => {
assert.deepEqual(users[0].username, 'virk')
})
- test('define expected number of rows', async (assert) => {
+ test('define expected number of rows', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2471,24 +2473,24 @@ test.group('Model | ManyToMany | whereHas', (group) => {
if (process.env.DB !== 'mysql_legacy') {
test.group('Model | ManyToMany | Group Limit', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply group limit', async (assert) => {
+ test('apply group limit', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2567,7 +2569,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(users[1].skills[1].$extras.pivot_skill_id, 4)
})
- test('apply group limit with extra constraints', async (assert) => {
+ test('apply group limit with extra constraints', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2690,7 +2692,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(users[1].skills[1].$extras.pivot_skill_id, 3)
})
- test('apply group limit and select custom columns', async (assert) => {
+ test('apply group limit and select custom columns', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2821,7 +2823,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(users[1].skills[1].$extras.pivot_proficiency, 'Master')
})
- test('define custom order by clause', async (assert) => {
+ test('define custom order by clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -2953,7 +2955,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.equal(users[1].skills[1].$extras.pivot_proficiency, 'Master')
})
- test('apply standard limit when not eagerloading', async (assert) => {
+ test('apply standard limit when not eagerloading', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3020,7 +3022,7 @@ if (process.env.DB !== 'mysql_legacy') {
assert.deepEqual(bindings, knexBindings)
})
- test('apply standard order by when not eagerloading', async (assert) => {
+ test('apply standard order by when not eagerloading', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3097,20 +3099,20 @@ if (process.env.DB !== 'mysql_legacy') {
}
test.group('Model | ManyToMany | wherePivot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('add where clause', async (assert) => {
+ test('add where clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3143,7 +3145,7 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where wrapped clause', async (assert) => {
+ test('add where wrapped clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3178,7 +3180,7 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where clause with operator', async (assert) => {
+ test('add where clause with operator', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3211,7 +3213,7 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where clause as a raw query', async (assert) => {
+ test('add where clause as a raw query', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3250,7 +3252,7 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhere clause', async (assert) => {
+ test('add orWhere clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3284,7 +3286,7 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhere wrapped clause', async (assert) => {
+ test('add orWhere wrapped clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3325,7 +3327,7 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('pass relationship metadata to the profiler', async (assert) => {
+ test('pass relationship metadata to the profiler', async ({ assert }) => {
assert.plan(1)
class Skill extends BaseModel {
@@ -3383,20 +3385,20 @@ test.group('Model | ManyToMany | wherePivot', (group) => {
})
test.group('Model | ManyToMany | whereNotPivot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('add where no clause', async (assert) => {
+ test('add where no clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3428,7 +3430,7 @@ test.group('Model | ManyToMany | whereNotPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where not clause with operator', async (assert) => {
+ test('add where not clause with operator', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3461,7 +3463,7 @@ test.group('Model | ManyToMany | whereNotPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where not clause as a raw query', async (assert) => {
+ test('add where not clause as a raw query', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3500,7 +3502,7 @@ test.group('Model | ManyToMany | whereNotPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhereNot clause', async (assert) => {
+ test('add orWhereNot clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3536,20 +3538,20 @@ test.group('Model | ManyToMany | whereNotPivot', (group) => {
})
test.group('Model | ManyToMany | whereInPivot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('add whereIn clause', async (assert) => {
+ test('add whereIn clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3582,7 +3584,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereIn as a query callback', async (assert) => {
+ test('add whereIn as a query callback', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3621,7 +3623,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereIn as a subquery', async (assert) => {
+ test('add whereIn as a subquery', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3659,7 +3661,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereIn as a rawquery', async (assert) => {
+ test('add whereIn as a rawquery', async ({ assert }) => {
const ref = db.connection().getWriteClient().ref.bind(db.connection().getWriteClient())
class Skill extends BaseModel {
@@ -3701,7 +3703,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereIn as a subquery with array of keys', async (assert) => {
+ test('add whereIn as a subquery with array of keys', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3739,7 +3741,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereIn as a 2d array', async (assert) => {
+ test('add whereIn as a 2d array', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3772,7 +3774,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhereIn clause', async (assert) => {
+ test('add orWhereIn clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3809,7 +3811,7 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhereIn as a query callback', async (assert) => {
+ test('add orWhereIn as a query callback', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3856,20 +3858,20 @@ test.group('Model | ManyToMany | whereInPivot', (group) => {
})
test.group('Model | ManyToMany | whereNotInPivot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('add whereNotIn clause', async (assert) => {
+ test('add whereNotIn clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3902,7 +3904,7 @@ test.group('Model | ManyToMany | whereNotInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereNotIn as a query callback', async (assert) => {
+ test('add whereNotIn as a query callback', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3941,7 +3943,7 @@ test.group('Model | ManyToMany | whereNotInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereNotIn as a sub query', async (assert) => {
+ test('add whereNotIn as a sub query', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -3979,7 +3981,7 @@ test.group('Model | ManyToMany | whereNotInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add whereNotIn as a 2d array', async (assert) => {
+ test('add whereNotIn as a 2d array', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4012,7 +4014,7 @@ test.group('Model | ManyToMany | whereNotInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhereNotIn clause', async (assert) => {
+ test('add orWhereNotIn clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4049,7 +4051,7 @@ test.group('Model | ManyToMany | whereNotInPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhereNotIn as a subquery', async (assert) => {
+ test('add orWhereNotIn as a subquery', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4096,20 +4098,20 @@ test.group('Model | ManyToMany | whereNotInPivot', (group) => {
})
test.group('Model | ManyToMany | whereNullPivot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('add where null clause', async (assert) => {
+ test('add where null clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4142,7 +4144,7 @@ test.group('Model | ManyToMany | whereNullPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where null wrapped clause', async (assert) => {
+ test('add where null wrapped clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4177,7 +4179,7 @@ test.group('Model | ManyToMany | whereNullPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhere null clause', async (assert) => {
+ test('add orWhere null clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4214,7 +4216,7 @@ test.group('Model | ManyToMany | whereNullPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhere null wrapped clause', async (assert) => {
+ test('add orWhere null wrapped clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4257,20 +4259,20 @@ test.group('Model | ManyToMany | whereNullPivot', (group) => {
})
test.group('Model | ManyToMany | whereNotNullPivot', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- test('add where not null clause', async (assert) => {
+ test('add where not null clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4303,7 +4305,7 @@ test.group('Model | ManyToMany | whereNotNullPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add where not null wrapped clause', async (assert) => {
+ test('add where not null wrapped clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4338,7 +4340,7 @@ test.group('Model | ManyToMany | whereNotNullPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhere not null clause', async (assert) => {
+ test('add orWhere not null clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4375,7 +4377,7 @@ test.group('Model | ManyToMany | whereNotNullPivot', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('add orWhere not null wrapped clause', async (assert) => {
+ test('add orWhere not null wrapped clause', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4418,24 +4420,24 @@ test.group('Model | ManyToMany | whereNotNullPivot', (group) => {
})
test.group('Model | ManyToMany | save', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('save related instance', async (assert) => {
+ test('save related instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4481,7 +4483,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('save related instance with pivot attributes', async (assert) => {
+ test('save related instance with pivot attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4530,7 +4532,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('do not attach duplicates when save is called more than once', async (assert) => {
+ test('do not attach duplicates when save is called more than once', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4578,7 +4580,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('perform update with different pivot attributes', async (assert) => {
+ test('perform update with different pivot attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4631,7 +4633,9 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('attach duplicates when save is called more than once with with checkExisting = false', async (assert) => {
+ test('attach duplicates when save is called more than once with with checkExisting = false', async ({
+ assert,
+ }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4682,7 +4686,9 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('attach duplicates with different pivot attributes and with checkExisting = false', async (assert) => {
+ test('attach duplicates with different pivot attributes and with checkExisting = false', async ({
+ assert,
+ }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4739,7 +4745,9 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('attach when related pivot entry exists but for a different parent @sanityCheck', async (assert) => {
+ test('attach when related pivot entry exists but for a different parent @sanityCheck', async ({
+ assert,
+ }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4794,7 +4802,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('save related instance with timestamps', async (assert) => {
+ test('save related instance with timestamps', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4845,7 +4853,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('do not set created_at on update', async (assert) => {
+ test('do not set created_at on update', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4901,7 +4909,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('do not set updated_at when disabled', async (assert) => {
+ test('do not set updated_at when disabled', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -4954,7 +4962,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('do not set created_at when disabled', async (assert) => {
+ test('do not set created_at when disabled', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5007,7 +5015,7 @@ test.group('Model | ManyToMany | save', (group) => {
assert.isUndefined(skill.$trx)
})
- test('do not set timestamps when disabled', async (assert) => {
+ test('do not set timestamps when disabled', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5057,24 +5065,24 @@ test.group('Model | ManyToMany | save', (group) => {
})
test.group('Model | ManyToMany | saveMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('save many of related instance', async (assert) => {
+ test('save many of related instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5127,7 +5135,7 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('save many of related instance with pivot attributes', async (assert) => {
+ test('save many of related instance with pivot attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5190,7 +5198,7 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('allow pivot rows without custom pivot attributes', async (assert) => {
+ test('allow pivot rows without custom pivot attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5251,7 +5259,7 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('do not attach duplicates when saveMany is called more than once', async (assert) => {
+ test('do not attach duplicates when saveMany is called more than once', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5305,7 +5313,7 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('update pivot row when saveMany is called more than once', async (assert) => {
+ test('update pivot row when saveMany is called more than once', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5376,7 +5384,9 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('attach duplicates when saveMany is called more than once with checkExisting = false', async (assert) => {
+ test('attach duplicates when saveMany is called more than once with checkExisting = false', async ({
+ assert,
+ }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5435,7 +5445,9 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('attach when related pivot entry exists but for a different parent @sanityCheck', async (assert) => {
+ test('attach when related pivot entry exists but for a different parent @sanityCheck', async ({
+ assert,
+ }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5498,7 +5510,7 @@ test.group('Model | ManyToMany | saveMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('wrap saveMany inside a custom transaction', async (assert) => {
+ test('wrap saveMany inside a custom transaction', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5555,24 +5567,24 @@ test.group('Model | ManyToMany | saveMany', (group) => {
})
test.group('Model | ManyToMany | create', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create related instance', async (assert) => {
+ test('create related instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5615,7 +5627,7 @@ test.group('Model | ManyToMany | create', (group) => {
assert.isUndefined(skill.$trx)
})
- test('create related instance with pivot attributes', async (assert) => {
+ test('create related instance with pivot attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5664,7 +5676,7 @@ test.group('Model | ManyToMany | create', (group) => {
assert.isUndefined(skill.$trx)
})
- test('wrap create inside a custom transaction', async (assert) => {
+ test('wrap create inside a custom transaction', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5714,24 +5726,24 @@ test.group('Model | ManyToMany | create', (group) => {
})
test.group('Model | ManyToMany | createMany', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('create many of related instance', async (assert) => {
+ test('create many of related instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5782,7 +5794,7 @@ test.group('Model | ManyToMany | createMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('create many of related instance with pivot attributes', async (assert) => {
+ test('create many of related instance with pivot attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5838,7 +5850,7 @@ test.group('Model | ManyToMany | createMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('allow pivot entries without custom attributes', async (assert) => {
+ test('allow pivot entries without custom attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5894,7 +5906,7 @@ test.group('Model | ManyToMany | createMany', (group) => {
assert.isUndefined(skill1.$trx)
})
- test('wrap create many inside a custom transaction', async (assert) => {
+ test('wrap create many inside a custom transaction', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -5942,24 +5954,24 @@ test.group('Model | ManyToMany | createMany', (group) => {
})
test.group('Model | ManyToMany | attach', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('attach one or more ids to the pivot table', async (assert) => {
+ test('attach one or more ids to the pivot table', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6002,7 +6014,7 @@ test.group('Model | ManyToMany | attach', (group) => {
assert.equal(skillUsers[1].skill_id, 2)
})
- test('attach with extra attributes', async (assert) => {
+ test('attach with extra attributes', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6056,24 +6068,24 @@ test.group('Model | ManyToMany | attach', (group) => {
})
test.group('Model | ManyToMany | detach', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('detach one or more ids from the pivot table', async (assert) => {
+ test('detach one or more ids from the pivot table', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6127,7 +6139,7 @@ test.group('Model | ManyToMany | detach', (group) => {
assert.equal(skillUsers[0].skill_id, 2)
})
- test('scope detach self to @sanityCheck', async (assert) => {
+ test('scope detach self to @sanityCheck', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6186,24 +6198,24 @@ test.group('Model | ManyToMany | detach', (group) => {
})
test.group('Model | ManyToMany | sync', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test("sync ids by dropping only the missing one's", async (assert) => {
+ test("sync ids by dropping only the missing one's", async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6267,7 +6279,7 @@ test.group('Model | ManyToMany | sync', (group) => {
assert.equal(skillUsers[1].skill_id, 1)
})
- test('keep duplicates of the id under sync', async (assert) => {
+ test('keep duplicates of the id under sync', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6331,7 +6343,7 @@ test.group('Model | ManyToMany | sync', (group) => {
assert.equal(skillUsers[1].skill_id, 1)
})
- test('update pivot rows when additional properties are changed', async (assert) => {
+ test('update pivot rows when additional properties are changed', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6401,7 +6413,7 @@ test.group('Model | ManyToMany | sync', (group) => {
assert.equal(skillUsers[1].proficiency, 'Master')
})
- test('do not update pivot row when no extra properties are defined', async (assert) => {
+ test('do not update pivot row when no extra properties are defined', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6467,7 +6479,7 @@ test.group('Model | ManyToMany | sync', (group) => {
assert.equal(skillUsers[1].proficiency, 'Master')
})
- test('do not remove rows when detach = false', async (assert) => {
+ test('do not remove rows when detach = false', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6538,7 +6550,7 @@ test.group('Model | ManyToMany | sync', (group) => {
assert.equal(skillUsers[2].proficiency, 'Master')
})
- test('do not remove rows when nothing has changed', async (assert) => {
+ test('do not remove rows when nothing has changed', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6609,7 +6621,7 @@ test.group('Model | ManyToMany | sync', (group) => {
assert.equal(skillUsers[2].proficiency, 'Master')
})
- test('use custom transaction', async (assert) => {
+ test('use custom transaction', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6696,24 +6708,24 @@ test.group('Model | ManyToMany | sync', (group) => {
})
test.group('Model | ManyToMany | pagination', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('paginate using related model query builder instance', async (assert) => {
+ test('paginate using related model query builder instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6775,7 +6787,7 @@ test.group('Model | ManyToMany | pagination', (group) => {
})
})
- test('disallow paginate during preload', async (assert) => {
+ test('disallow paginate during preload', async ({ assert }) => {
assert.plan(1)
class Skill extends BaseModel {
@@ -6821,24 +6833,24 @@ test.group('Model | ManyToMany | pagination', (group) => {
})
test.group('Model | ManyToMany | clone', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('clone related model query builder', async (assert) => {
+ test('clone related model query builder', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6878,24 +6890,24 @@ test.group('Model | ManyToMany | clone', (group) => {
})
test.group('Model | ManyToMany | scopes', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('apply scopes during eagerload', async (assert) => {
+ test('apply scopes during eagerload', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -6948,7 +6960,7 @@ test.group('Model | ManyToMany | scopes', (group) => {
assert.equal(user.skills[0].name, 'Programming')
})
- test('apply scopes on related query', async (assert) => {
+ test('apply scopes on related query', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -7002,24 +7014,24 @@ test.group('Model | ManyToMany | scopes', (group) => {
})
test.group('Model | ManyToMany | onQuery', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('invoke onQuery method when preloading relationship', async (assert) => {
+ test('invoke onQuery method when preloading relationship', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -7062,7 +7074,7 @@ test.group('Model | ManyToMany | onQuery', (group) => {
assert.equal(user.skills[0].name, 'Programming')
})
- test('do not invoke onQuery method during preloading subqueries', async (assert) => {
+ test('do not invoke onQuery method during preloading subqueries', async ({ assert }) => {
assert.plan(3)
class Skill extends BaseModel {
@@ -7115,7 +7127,7 @@ test.group('Model | ManyToMany | onQuery', (group) => {
assert.equal(user.skills[0].name, 'Programming')
})
- test('invoke onQuery method on related query builder', async (assert) => {
+ test('invoke onQuery method on related query builder', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -7159,7 +7171,7 @@ test.group('Model | ManyToMany | onQuery', (group) => {
assert.equal(skills[0].name, 'Programming')
})
- test('invoke onQuery method on pivot query builder', async (assert) => {
+ test('invoke onQuery method on pivot query builder', async ({ assert }) => {
assert.plan(4)
class Skill extends BaseModel {
@@ -7212,24 +7224,24 @@ test.group('Model | ManyToMany | onQuery', (group) => {
})
test.group('Model | ManyToMany | delete', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('delete related instance', async (assert) => {
+ test('delete related instance', async ({ assert }) => {
class Skill extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/orm/model-query-builder.spec.ts b/test/orm/model-query-builder.spec.ts
index 18b385d5..a1cf4843 100644
--- a/test/orm/model-query-builder.spec.ts
+++ b/test/orm/model-query-builder.spec.ts
@@ -9,7 +9,7 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { column } from '../../src/Orm/Decorators'
import { scope } from '../../src/Helpers/scope'
import { ModelQueryBuilder } from '../../src/Orm/QueryBuilder'
@@ -30,24 +30,24 @@ let app: ApplicationContract
let BaseModel: ReturnType
test.group('Model query builder', (group) => {
- group.before(async () => {
+ group.setup(async () => {
app = await setupApplication()
db = getDb(app)
BaseModel = getBaseModel(ormAdapter(db), app)
await setup()
})
- group.after(async () => {
+ group.teardown(async () => {
await db.manager.closeAll()
await cleanup()
await fs.cleanup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await resetTables()
})
- test('get instance of query builder for the given model', async (assert) => {
+ test('get instance of query builder for the given model', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -60,7 +60,7 @@ test.group('Model query builder', (group) => {
assert.instanceOf(User.query(), ModelQueryBuilder)
})
- test('pre select the table for the query builder instance', async (assert) => {
+ test('pre select the table for the query builder instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -73,7 +73,7 @@ test.group('Model query builder', (group) => {
assert.equal(User.query().knexQuery['_single'].table, 'users')
})
- test('execute select queries', async (assert) => {
+ test('execute select queries', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -94,7 +94,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(users[0].$attributes, { id: 1, username: 'virk' })
})
- test('pass custom connection to the model instance', async (assert) => {
+ test('pass custom connection to the model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -116,7 +116,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(users[0].$options!.connection, 'secondary')
})
- test('pass sideloaded attributes to the model instance', async (assert) => {
+ test('pass sideloaded attributes to the model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -141,7 +141,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(users[0].$sideloaded, { loggedInUser: { id: 1 } })
})
- test('pass custom profiler to the model instance', async (assert) => {
+ test('pass custom profiler to the model instance', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -164,7 +164,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(users[0].$options!.profiler, profiler)
})
- test('perform update using model query builder', async (assert) => {
+ test('perform update using model query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -187,7 +187,7 @@ test.group('Model query builder', (group) => {
assert.equal(user!.username, 'hvirk')
})
- test('perform increment using model query builder', async (assert) => {
+ test('perform increment using model query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -210,7 +210,7 @@ test.group('Model query builder', (group) => {
assert.equal(user!.points, 2)
})
- test('perform decrement using model query builder', async (assert) => {
+ test('perform decrement using model query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -233,7 +233,7 @@ test.group('Model query builder', (group) => {
assert.equal(user!.points, 2)
})
- test('delete in bulk', async (assert) => {
+ test('delete in bulk', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -256,7 +256,7 @@ test.group('Model query builder', (group) => {
assert.isNull(user)
})
- test('clone query builder', async (assert) => {
+ test('clone query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -272,7 +272,7 @@ test.group('Model query builder', (group) => {
assert.instanceOf(clonedQuery, ModelQueryBuilder)
})
- test('clone query builder with internal flags', async (assert) => {
+ test('clone query builder with internal flags', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -288,7 +288,7 @@ test.group('Model query builder', (group) => {
assert.isTrue(clonedQuery.hasGroupBy)
})
- test('pass sideloaded data to cloned query', async (assert) => {
+ test('pass sideloaded data to cloned query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -308,7 +308,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(user.$sideloaded, { username: 'virk' })
})
- test('apply scopes', async (assert) => {
+ test('apply scopes', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -339,7 +339,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('apply scopes inside a sub query', async (assert) => {
+ test('apply scopes inside a sub query', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@@ -370,7 +370,7 @@ test.group('Model query builder', (group) => {
assert.deepEqual(bindings, knexBindings)
})
- test('make aggregate queries with the model query builder', async (assert) => {
+ test('make aggregate queries with the model query builder', async ({ assert }) => {
class User extends BaseModel {
@column({ isPrimary: true })
public id: number
diff --git a/test/seeds/seeders-source.spec.ts b/test/seeds/seeders-source.spec.ts
index 5dd89b69..5fe58442 100644
--- a/test/seeds/seeders-source.spec.ts
+++ b/test/seeds/seeders-source.spec.ts
@@ -7,23 +7,23 @@
* file that was distributed with this source code.
*/
-import test from 'japa'
+import { test } from '@japa/runner'
import { join } from 'path'
import { SeedersSource } from '../../src/SeedsRunner/SeedersSource'
import { getDb, setup, setupApplication, fs, cleanup } from '../../test-helpers'
test.group('Seeds Source', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('get list of seed files recursively', async (assert) => {
+ test('get list of seed files recursively', async ({ assert }) => {
const app = await setupApplication()
const db = getDb(app)
@@ -57,7 +57,7 @@ test.group('Seeds Source', (group) => {
)
})
- test('only pick .ts/.js files', async (assert) => {
+ test('only pick .ts/.js files', async ({ assert }) => {
const app = await setupApplication()
const db = getDb(app)
const seedsSource = new SeedersSource(db.getRawConnection('primary')!.config, app)
@@ -96,7 +96,7 @@ test.group('Seeds Source', (group) => {
)
})
- test('sort multiple seeders directories seperately', async (assert) => {
+ test('sort multiple seeders directories seperately', async ({ assert }) => {
const app = await setupApplication()
const db = getDb(app)
diff --git a/test/seeds/seeds-runner.spec.ts b/test/seeds/seeds-runner.spec.ts
index a8f16366..81af3260 100644
--- a/test/seeds/seeds-runner.spec.ts
+++ b/test/seeds/seeds-runner.spec.ts
@@ -7,22 +7,22 @@
* file that was distributed with this source code.
*/
-import test from 'japa'
+import { test } from '@japa/runner'
import { SeedsRunner } from '../../src/SeedsRunner'
import { getDb, setup, cleanup, setupApplication, fs } from '../../test-helpers'
test.group('Seeds Runner', (group) => {
- group.beforeEach(async () => {
+ group.each.setup(async () => {
await setup()
})
- group.afterEach(async () => {
+ group.each.teardown(async () => {
await cleanup()
await fs.cleanup()
})
- test('run a seeder file', async (assert) => {
+ test('run a seeder file', async ({ assert }) => {
const app = await setupApplication()
const db = getDb(app)
const runner = new SeedsRunner(db, app)
@@ -46,7 +46,7 @@ test.group('Seeds Runner', (group) => {
await db.manager.closeAll()
})
- test('catch and return seeder errors', async (assert) => {
+ test('catch and return seeder errors', async ({ assert }) => {
const app = await setupApplication()
const db = getDb(app)
const runner = new SeedsRunner(db, app)
@@ -68,7 +68,9 @@ test.group('Seeds Runner', (group) => {
await db.manager.closeAll()
})
- test('mark file as ignored when "developmentOnly = true" and not running in development mode', async (assert) => {
+ test('mark file as ignored when "developmentOnly = true" and not running in development mode', async ({
+ assert,
+ }) => {
process.env.NODE_ENV = 'production'
const app = await setupApplication()
diff --git a/test/utils.spec.ts b/test/utils.spec.ts
index 3a41f01a..422361da 100644
--- a/test/utils.spec.ts
+++ b/test/utils.spec.ts
@@ -9,11 +9,11 @@
///
-import test from 'japa'
+import { test } from '@japa/runner'
import { syncDiff } from '../src/utils'
test.group('Utils | syncDiff', () => {
- test('return ids to be added', (assert) => {
+ test('return ids to be added', ({ assert }) => {
const dbRows = {
1: {
id: '1',
@@ -36,7 +36,7 @@ test.group('Utils | syncDiff', () => {
})
})
- test('return ids to be updated when attributes are different', (assert) => {
+ test('return ids to be updated when attributes are different', ({ assert }) => {
const dbRows = {
1: {
id: '1',
@@ -63,7 +63,7 @@ test.group('Utils | syncDiff', () => {
})
})
- test('ignore rows whose attributes are same', (assert) => {
+ test('ignore rows whose attributes are same', ({ assert }) => {
const dbRows = {
1: {
id: '1',