diff --git a/src/orm/decorators/date_time.ts b/src/orm/decorators/date_time.ts index ca617056..e32bc98a 100644 --- a/src/orm/decorators/date_time.ts +++ b/src/orm/decorators/date_time.ts @@ -47,7 +47,7 @@ function prepareDateTimeColumn(value: any, attributeName: string, modelInstance: */ throw new errors.E_INVALID_DATE_COLUMN_VALUE([ `${modelName}.${attributeName}`, - 'It must be an instance of "luxon.DateTime', + 'It must be an instance of "luxon.DateTime"', ]) } diff --git a/test/migrations/migrator.spec.ts b/test/migrations/migrator.spec.ts index 0b7c76ea..261f9641 100644 --- a/test/migrations/migrator.spec.ts +++ b/test/migrations/migrator.spec.ts @@ -18,6 +18,7 @@ import { getMigrator, cleanup as cleanupTables, } from '../../test-helpers/index.js' +import * as errors from '../../src/errors.js' test.group('Migrator', (group) => { group.each.setup(async () => { @@ -834,7 +835,7 @@ test.group('Migrator', (group) => { const db = getDb() cleanup(() => db.manager.closeAll()) - assert.plan(4) + assert.plan(5) await fs.create( 'database/migrations/users_v11.ts', @@ -892,9 +893,10 @@ test.group('Migrator', (group) => { assert.lengthOf(migrated, 2) assert.isTrue(hasUsersTable) assert.isTrue(hasAccountsTable) + assert.instanceOf(migrator1.error, errors.E_MISSING_SCHEMA_FILES) assert.equal( migrator1.error!.message, - 'Cannot perform rollback. Schema file {database/migrations/accounts_v11} is missing' + 'Cannot perform rollback. Schema file "database/migrations/accounts_v11" is missing' ) }) diff --git a/test/orm/base_model.spec.ts b/test/orm/base_model.spec.ts index 2debdafa..634917d7 100644 --- a/test/orm/base_model.spec.ts +++ b/test/orm/base_model.spec.ts @@ -53,6 +53,7 @@ import { LucidRow } from '../../src/types/model.js' import { ModelPaginator } from '../../src/orm/paginator/index.js' import { SimplePaginator } from '../../src/database/paginator/simple_paginator.js' import { SnakeCaseNamingStrategy } from '../../src/orm/naming_strategies/snake_case.js' +import * as errors from '../../src/errors.js' test.group('Base model | boot', (group) => { group.setup(async () => { @@ -6018,7 +6019,7 @@ test.group('Base Model | date', (group) => { }) test('raise error when date column value is unprocessable', async ({ fs, assert }) => { - assert.plan(1) + assert.plan(2) const app = new AppFactory().create(fs.baseUrl, () => {}) await app.init() @@ -6044,8 +6045,12 @@ test.group('Base Model | date', (group) => { user.dob = 10 as any try { await user.save() - } catch ({ message }) { - assert.equal(message, 'The value for "User.dob" must be an instance of "luxon.DateTime"') + } catch (error) { + assert.instanceOf(error, errors.E_INVALID_DATE_COLUMN_VALUE) + assert.equal( + error.message, + 'Invalid value for "User.dob". The value must be an instance of "luxon.DateTime"' + ) } }) @@ -6414,7 +6419,7 @@ test.group('Base Model | datetime', (group) => { }) test('raise error when datetime column value is unprocessable', async ({ fs, assert }) => { - assert.plan(1) + assert.plan(2) const app = new AppFactory().create(fs.baseUrl, () => {}) await app.init() @@ -6440,8 +6445,12 @@ test.group('Base Model | datetime', (group) => { user.dob = 10 as any try { await user.save() - } catch ({ message }) { - assert.equal(message, 'The value for "User.dob" must be an instance of "luxon.DateTime"') + } catch (error) { + assert.instanceOf(error, errors.E_INVALID_DATE_COLUMN_VALUE) + assert.equal( + error.message, + 'Invalid value for "User.dob". It must be an instance of "luxon.DateTime"' + ) } })