Repository navigation
fix(pgsql-test): expectError keeps the original error when its savepoint cleanup fails - #1926
Merged
Merged
Conversation
…riginal error; reset lastIndex on /g matchers
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. No issues found — approved ✅. This PR introduces an
Reviewed commit: ce279e2 |
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.
Summary
This is a follow-up to #1925 and addresses the review finding on the
finallycleanup.Before:
PgTestClient.expectErrorranROLLBACK TO+RELEASEin an unguardedfinally. Ifrun()had ended the transaction (ROLLBACK/COMMIT) or broken the connection, the cleanup error replaced the original error. The test then failed with a bareROLLBACK TO SAVEPOINT can only be used in transaction blocks, and the error that would have explained the failure was lost.After: cleanup runs in its own
try. If it fails,expectErrorthrows one error that names both errors. Nothing is swallowed.causeis set to the original error. Ifrun()succeeded,causeis the cleanup error instead.The PR also fixes a smaller bug:
matchesTextnow resetspattern.lastIndex. Before, a/gRegExp that was reused across calls matched on the first call and missed on the second.Regression evidence: I added 3 tests to
postgres-test.expect-error.test.ts. Onmainthey fail as follows:With this change, all 11 tests in the suite pass.
Link to Devin session: https://app.devin.ai/sessions/fac9ca826fe6497ab29b806da19de770
Open in Devin Desktop: https://app.devin.ai/desktop/session/fac9ca826fe6497ab29b806da19de770?variant=devin
Requested by: @pyramation