Skip to content

use target patterns for test overrides (5/8) - #39352

Merged
jbardin merged 1 commit into
mainfrom
jbardin/target-patterns-E
Oct 9, 2026
Merged

jbardin merged 1 commit into
mainfrom
jbardin/target-patterns-E

Conversation

@jbardin

@jbardin jbardin commented Oct 7, 2026

Copy link
Copy Markdown
Member

The targets of override blocks in test files and mock providers are parsed as target patterns, so an override of a module call or resource without an instance key applies to every instance. Override targets are stored in addrs.Map[addrs.TargetPattern, *Override], and Config.TargetExists checks the configuration address of the pattern.

Overrides are found by matching their targets against each address, and the most specific of the matching overrides is used. Overrides from the test configuration take precedence over those from mock providers with the same target.

@jbardin jbardin added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Oct 7, 2026
@jbardin jbardin changed the title use target patterns for test overrides use target patterns for test overrides (5/8) Oct 7, 2026
@jbardin
jbardin force-pushed the jbardin/target-patterns-D branch from 82d4781 to e4cae21 Compare October 8, 2026 15:28
The targets of override blocks in test files and mock providers are
parsed as target patterns, so an override of a module call or resource
without an instance key applies to every instance. Override targets are
stored in addrs.Map[addrs.TargetPattern, *Override], and
Config.TargetExists checks the configuration address of the pattern.

Overrides are found by matching their targets against each address, and
the most specific of the matching overrides is used. Overrides from the
test configuration take precedence over those from mock providers with
the same target.
@jbardin
jbardin force-pushed the jbardin/target-patterns-E branch from 3af93a7 to 1560520 Compare October 8, 2026 15:47
@jbardin
jbardin marked this pull request as ready for review October 8, 2026 15:50
@jbardin
jbardin requested a review from a team as a code owner October 8, 2026 15:50
mildwonkey
mildwonkey previously approved these changes Oct 8, 2026

@mildwonkey mildwonkey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point I'm approving based on the past PRs, tests, and general design pattern more than specific changes (I don't know test well) but this all still looks reasonable!

Base automatically changed from jbardin/target-patterns-D to main October 8, 2026 19:02
@jbardin
jbardin dismissed mildwonkey’s stale review October 8, 2026 19:02

The base branch was changed.

@jbardin
jbardin merged commit abb9b68 into main Oct 9, 2026
17 checks passed
@jbardin
jbardin deleted the jbardin/target-patterns-E branch October 9, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants