-
Notifications
You must be signed in to change notification settings - Fork 75
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
Lf 4170 create or modify animal enum tables #3252
base: integration
Are you sure you want to change the base?
Lf 4170 create or modify animal enum tables #3252
Conversation
|
||
export const up = async function (knex) { | ||
// Synchronize the permissions_permission_id_seq sequence with the latest permission_id value. | ||
await knex.raw(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to let the db auto generate the permission id for new rows because it's currently out of sync and you have to manually look it up and add it in.
@navDhammu Sorry it is taking a little longer to review than normal! We have had a lot of unexpected coding challenges happen this month and have been focusing on the Soil Health V1 ready for release. Apologies if it take a little longer. In my opinion -- I really dislike our existing backend tests haha. So I am definitely open to that POC/discussion sometime after this release! My pet peeves with the tests are:
|
@Duncan-Brain No worries! Btw, not related to this ticket but I worked on an experimental PR which I thought might be useful. Once you have the time, if you can have a look and provide some feedback that would be appreciated! |
Description
This PR includes some migrations, api for /animal_identifier_types and some small changes to the animal_identifier_placements api as specified in ticket: https://lite-farm.atlassian.net/browse/LF-4170
While working on this I had some issues with some of the tests. I'm not sure if its just me but when I create a new test database and run the migrations on it, I get some errors when trying to run individual files like
animal_identifier_test
(and some other files too). Its happening because initially the database has several constant tables with values already present in them like animal colors and placements, and the cleanup is done in theafterEach
method which means that when the first test is executed the tables are not in an empty state and this is resulting in some errors. It doesn't happen when you run all the tests withnpm run test
because the test that runs first doesn't rely on any non-empty tables so when its finished, the cleanup is done in afterEach and all subsequent tests run with a clean state making all tests pass.Going further on this topic, I had some ideas on improving on the overall testing strategy. Rather than running a cleanup of the whole db after each test, it may be better to run each test in a transaction and rollback once its complete, potentially eliminating the need to manually do the cleanup and maintain a list of tables that need to be cleaned in
testEnvironment.js
. Also it might make the tests run a bit faster.If the dev team @Duncan-Brain , @SayakaOno , @kathyavini is alright with this, I can try to create a sample PR as a proof of concept.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: