test(baked_in): add regression test for postcode_iso3166_alpha2_field issue #1314 - #1586
Open
64johnlee wants to merge 1 commit into
Open
test(baked_in): add regression test for postcode_iso3166_alpha2_field issue #1314#158664johnlee wants to merge 1 commit into
64johnlee wants to merge 1 commit into
Conversation
… issue go-playground#1314 Adds TestPostCodeByIso3166Alpha2Field_Issue1314 to confirm that postcode_iso3166_alpha2_field works correctly when WithRequiredStructEnabled() is used — the exact scenario broken in v10.21.0 after PR go-playground#1270 changed iso3166 maps from map[string]bool to map[string]struct{}. The underlying fix (adding postcodeRegexInit.Do(initPostcodes) before the dict lookup in isPostcodeByIso3166Alpha2Field) is already present in HEAD; this test prevents future regressions. Closes go-playground#1314 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Adds a regression test (
TestPostCodeByIso3166Alpha2Field_Issue1314) that directly reproduces the scenario from issue #1314: usingpostcode_iso3166_alpha2_fieldwithWithRequiredStructEnabled().The underlying bug (missing
postcodeRegexInit.Do(initPostcodes)call inisPostcodeByIso3166Alpha2Field) was introduced by PR #1270 and has since been fixed in HEAD. However, no test existed for the exactWithRequiredStructEnabled()scenario reported in the issue, leaving the door open for future regressions.Closes #1314
Changes
validator_test.go— addsTestPostCodeByIso3166Alpha2Field_Issue1314covering the valid and invalid postcode cases withWithRequiredStructEnabled()Test plan
PATH=/home/user/go/bin:$PATH go test ./...passes (all 24 packages)TestPostCodeByIso3166Alpha2Field_Issue1314passes, confirming the fix is in placeTestPostCodeByIso3166Alpha2Field*tests continue to pass