Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test helpers to use Objection #72

Merged
merged 5 commits into from
Dec 22, 2022

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Dec 22, 2022

This is in support of Improve model tests

Currently, our test helpers create records using Knex directly. This is a result of the initial helpers being added before we implemented Objection.js.

We want to expand some of our tests plus there is an argument to be consistent in how we interact with the tables in our DB. So, this change updates the helpers to do things via Objection and fixes any tests we break.

** Notes

  • We switch to immediately returning the result on the basis the calling method will await the result. This removes the need to declare the method async.
  • We update the services to use the correct case
  • We update the helpers to be consistent with their module.exports

> This is in support of [Improve model tests](#71)

Currently, our test helpers create records using Knew directly. This is a result of the initial helpers being added before we implemented [Objection.js](https://vincit.github.io/objection.js/).

We want to expand some of our tests plus there is an argument to be consistent in how we interact with the tables in our DB. So, this change updates the helpers to do things via Objection and fixes any tests we break as a result.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Dec 22, 2022
@Cruikshanks Cruikshanks self-assigned this Dec 22, 2022
Whilst doing this we switch to immediately returning the result on the basis the calling method will `await` the result. This removes the need to declare the method `async`.
As things are going through Objection.js and we have `knexSnakeCaseMappers` setup we shouldn't be use snake_case in our queries.
@Cruikshanks Cruikshanks marked this pull request as ready for review December 22, 2022 15:56
@Cruikshanks Cruikshanks requested review from Jozzey and removed request for Jozzey December 22, 2022 15:56
@Cruikshanks
Copy link
Member Author

Abusing my tech lead powers so I can get on with #71 😁 !

@Cruikshanks Cruikshanks merged commit f65f3fe into main Dec 22, 2022
@Cruikshanks Cruikshanks deleted the update-helpers-to-use-objection branch December 22, 2022 16:37
Copy link
Contributor

@Jozzey Jozzey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants