From 0ff68f23f33970a6ca553516a31d31e65b066cb4 Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Thu, 28 Nov 2024 09:12:19 +0100 Subject: [PATCH] tests(errors): improve message for missing attribute error --- test/orm/model_belongs_to.spec.ts | 7 +++++-- test/orm/model_has_many.spec.ts | 7 +++++-- test/orm/model_has_many_through.spec.ts | 11 +++++++---- test/orm/model_has_one.spec.ts | 7 +++++-- test/orm/model_many_to_many.spec.ts | 10 ++++++++-- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/test/orm/model_belongs_to.spec.ts b/test/orm/model_belongs_to.spec.ts index 41b30a20..4b547fbf 100644 --- a/test/orm/model_belongs_to.spec.ts +++ b/test/orm/model_belongs_to.spec.ts @@ -53,7 +53,10 @@ test.group('Model | BelongsTo | Options', (group) => { Profile.boot() Profile.$getRelation('user')!.boot() } catch ({ message }) { - assert.equal(message, '"Profile.user" expects "id" to exist on "User" model, but is missing') + assert.equal( + message, + 'Relation "Profile.user" expects "id" to exist on "User" model, but is missing. Did you forget to define the column?' + ) } }) @@ -84,7 +87,7 @@ test.group('Model | BelongsTo | Options', (group) => { } catch ({ message }) { assert.equal( message, - '"Profile.user" expects "userId" to exist on "Profile" model, but is missing' + 'Relation "Profile.user" expects "userId" to exist on "Profile" model, but is missing. Did you forget to define the column?' ) } }) diff --git a/test/orm/model_has_many.spec.ts b/test/orm/model_has_many.spec.ts index b602a980..86835702 100644 --- a/test/orm/model_has_many.spec.ts +++ b/test/orm/model_has_many.spec.ts @@ -55,7 +55,10 @@ test.group('Model | HasMany | Options', (group) => { User.boot() User.$getRelation('posts')!.boot() } catch ({ message }) { - assert.equal(message, '"User.posts" expects "id" to exist on "User" model, but is missing') + assert.equal( + message, + 'Relation "User.posts" expects "id" to exist on "User" model, but is missing. Did you forget to define the column?' + ) } }) @@ -85,7 +88,7 @@ test.group('Model | HasMany | Options', (group) => { } catch ({ message }) { assert.equal( message, - '"User.posts" expects "userId" to exist on "Post" model, but is missing' + 'Relation "User.posts" expects "userId" to exist on "Post" model, but is missing. Did you forget to define the column?' ) } }) diff --git a/test/orm/model_has_many_through.spec.ts b/test/orm/model_has_many_through.spec.ts index 0f6841a8..f99f57ee 100644 --- a/test/orm/model_has_many_through.spec.ts +++ b/test/orm/model_has_many_through.spec.ts @@ -58,7 +58,7 @@ test.group('Model | Has Many Through | Options', (group) => { } catch ({ message }) { assert.equal( message, - '"Country.posts" expects "id" to exist on "Country" model, but is missing' + 'Relation "Country.posts" expects "id" to exist on "Country" model, but is missing. Did you forget to define the column?' ) } }) @@ -92,7 +92,7 @@ test.group('Model | Has Many Through | Options', (group) => { } catch ({ message }) { assert.equal( message, - '"Country.posts" expects "countryId" to exist on "User" model, but is missing' + 'Relation "Country.posts" expects "countryId" to exist on "User" model, but is missing. Did you forget to define the column?' ) } }) @@ -127,7 +127,10 @@ test.group('Model | Has Many Through | Options', (group) => { Country.boot() Country.$getRelation('posts')!.boot() } catch ({ message }) { - assert.equal(message, '"Country.posts" expects "id" to exist on "User" model, but is missing') + assert.equal( + message, + 'Relation "Country.posts" expects "id" to exist on "User" model, but is missing. Did you forget to define the column?' + ) } }) @@ -166,7 +169,7 @@ test.group('Model | Has Many Through | Options', (group) => { } catch ({ message }) { assert.equal( message, - '"Country.posts" expects "userId" to exist on "Post" model, but is missing' + 'Relation "Country.posts" expects "userId" to exist on "Post" model, but is missing. Did you forget to define the column?' ) } }) diff --git a/test/orm/model_has_one.spec.ts b/test/orm/model_has_one.spec.ts index 5f2120c1..72aace33 100644 --- a/test/orm/model_has_one.spec.ts +++ b/test/orm/model_has_one.spec.ts @@ -53,7 +53,10 @@ test.group('Model | HasOne | Options', (group) => { User.boot() User.$getRelation('profile')!.boot() } catch ({ message }) { - assert.equal(message, '"User.profile" expects "id" to exist on "User" model, but is missing') + assert.equal( + message, + 'Relation "User.profile" expects "id" to exist on "User" model, but is missing. Did you forget to define the column?' + ) } }) @@ -83,7 +86,7 @@ test.group('Model | HasOne | Options', (group) => { } catch ({ message }) { assert.equal( message, - '"User.profile" expects "userId" to exist on "Profile" model, but is missing' + 'Relation "User.profile" expects "userId" to exist on "Profile" model, but is missing. Did you forget to define the column?' ) } }) diff --git a/test/orm/model_many_to_many.spec.ts b/test/orm/model_many_to_many.spec.ts index c1444f57..42bae9f3 100644 --- a/test/orm/model_many_to_many.spec.ts +++ b/test/orm/model_many_to_many.spec.ts @@ -57,7 +57,10 @@ test.group('Model | ManyToMany | Options', (group) => { User.boot() User.$getRelation('skills')!.boot() } catch ({ message }) { - assert.equal(message, '"User.skills" expects "id" to exist on "User" model, but is missing') + assert.equal( + message, + 'Relation "User.skills" expects "id" to exist on "User" model, but is missing. Did you forget to define the column?' + ) } }) @@ -141,7 +144,10 @@ test.group('Model | ManyToMany | Options', (group) => { User.boot() User.$getRelation('skills')!.boot() } catch ({ message }) { - assert.equal(message, '"User.skills" expects "id" to exist on "Skill" model, but is missing') + assert.equal( + message, + 'Relation "User.skills" expects "id" to exist on "Skill" model, but is missing. Did you forget to define the column?' + ) } })