Create integration tests
Closed this issue · 4 comments
k4m4 commented
Tests need to be written to achieve the following:
- Mock the GitHub Authentication Strategy:
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/auth/passport.js#L24-L25 - Mock time to trigger the
ingestMetricsJob
twice - atmidnight
& atmidnight + 1 week
:
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/workers/jobs.js#L4-L16
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/config.js#L40-L45
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/workers/queues.js#L10-L13
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/workers/metrics.js#L49-L56 - Mock time to trigger the
sendEmailJob
:
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/workers/jobs.js#L18-L34
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/config.js#L40-L45
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/workers/queues.js#L15-L19
https://github.com/Meeshkan/vanity/blob/294d8be838ec338dc92ec0455fb999c97ac9f970/backend/workers/email.js#L51-L62
mikesol commented
A few things:
- I would not worry about testing the passport strategy. Instead, I would post an alert to Sentry if the failure URL is called for any reason, spewing as much info as possible.
- Could we move the asynchronous jobs to Zenaton? I read the code and get how the redis cue is working, but I'd recommend migrating to Zenaton as it will make things easier at this stage. If so, we can chat more about how to do that, but I wanted to get your confirmation first before doing that.
mikesol commented
I just read up on testing cron jobs. The general idea is to:
- create a test that the cron job is equal to the one that is expected (this is just string comparison)
- create a test that bull registers the job
- create a test of the execution
These should be sufficient to have high confidence.
k4m4 commented
I feel like testing the cron jobs themselves is unnecessary at this point in time. In my opinion, we should trust that Bull will run our tasks when it's supposed to and instead write unit tests for the functions that are executed by Bull.