bj-rutledge / CRUD-API-Example

Simple Example of a CRUD API
MIT License
1 stars 3 forks source link

Database tests fail if they are run together. #66

Open bj-rutledge opened 11 months ago

bj-rutledge commented 11 months ago

When tests hitting the db are ran together they fail. I'm thinking it has to do with the connection being open/closed on hits. Need to research this and figure out what's happening. I tried awaiting the db.close but that's not likely possible in some instances when we're returning a promise from a non async function. Again, need to research a bit and possibly refactor the route code. Currently it's modular, in that the function that hits the db is in the DAL. It may be that we just need to put it directly in the route so that we can close it then without having to worry about defining additional async functions.

stawuah commented 9 months ago

When testing data insertion into the database, I prefer writing unit tests for individual functions, treating them as edge cases instead of testing the entire insertion process as a whole.

A good first issue should be :