Repository navigation
test(repositories): add unit tests for the notification outbox, delivery log and nip05 verification repositories - #918
Open
Priyanshubhartistm wants to merge 2 commits into
Conversation
…ery log and nip05 verification repositories Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
🦋 Changeset detectedLatest commit: 229a475 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
[Low impact] The PR appears safe to merge, with all three previous findings addressed.
|
Collaborator
Coverage Report for CI Build 39485282477Coverage increased (+0.7%) to 74.451%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
…he last_checked_at fallback Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds unit specs for the three repositories that had none:
notification-outbox,notification-delivery-logandnip05-verification. No production code changes.They run the repositories' real knex queries on the postgres dialect through a small recording client (
test/unit/repositories/recording-knex.ts) that never connects: each statement and its bindings are recorded and answered with scripted rows or counts, so the specs assert on the SQL that would run, not on stubbed repository methods.enqueue(pending, due now, unattempted),claimBatch(due pending plus processing rows whose 5 minute lease ran out, oldest first,for update skip locked, claimed rows marked processing),markDelivered,markFailed(back to pending with exponential backoff capped at a minute, dead once attempts are used up, error truncated to 2000 characters),deleteTerminalOlderThan(delivered and dead only).appendfor success, failure and test notifications,findSuccessfulTargetIds(successes only, so a retry skips delivered targets),findRecent(default limit and each filter),deleteOlderThan.findByPubkey,upsert(what is updated on conflict),findPendingVerifications,deleteByPubkey, andlistForAdmin(each filter, stale and fresh, the filters combined, count and page filtered alike, pagination).Related Issue
Closes #905
Motivation and Context
The notification outbox service spec stubs its repository, so the SQL of the repository was never run by a test, and
listForAdminalready serves the admin API untested.claimBatchis asserted on its query (locking and skipping locked rows); that two workers never receive the same message is guaranteed by PostgreSQL, so it is not something a unit test can show.How Has This Been Tested?
skipLocked, changing the backoff cap or the dead threshold, dropping the success filter, the null check of the stale filter or the clone of the count query each make a spec fail.pnpm lint,pnpm check:deps,pnpm run build:check,pnpm run test:unit.Screenshots (if appropriate):
Types of changes
Checklist: