test: add HandleContext abort regression tests for internal redirect (#2944) - #4790
Open
stareezy-1 wants to merge 1 commit into
Open
test: add HandleContext abort regression tests for internal redirect (#2944)#4790stareezy-1 wants to merge 1 commit into
stareezy-1 wants to merge 1 commit into
Conversation
…in-gonic#2944) When a route internally redirects via HandleContext and the target chain's middleware aborts, the target handler must not run after HandleContext returns. These tests pin the behavior fixed by gin-gonic#3987; both fail without the handlers-restore fix.
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.
What
Adds two regression tests for the internal-redirect abort scenario reported in #2944:
TestEngineHandleContextAbortPreventsTargetHandlerTestEngineHandleContextAbortWithNextPreventsTargetHandlerWhy
#2944 reports that when a route internally redirects via
HandleContextand the target chain's middleware callsAbort, the target handler still runs ({"result":"mid"}{"result":"t2"}).The behavior was fixed by #3987 (which restores
c.handlersafter re-entry), but no regression test covers the abort path — the existingTestEngineHandleContextPreventsMiddlewareReEntryonly counts handler invocations without aborting.Verification
Both tests fail against
8763f33~1(pre-#3987 code) with the reported double output, and pass on master. Full suite passes:go test ./....