Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of conflicting dynamic parameters #2592

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benjaminfuchs
Copy link

@benjaminfuchs benjaminfuchs commented Dec 20, 2024

PR Summary

Fix #1274

This pull request resolves the issue where mocked functions fail to handle dynamic parameters with conflicting names (e.g., PSEdition).

Changes:

  • Added Repair-ConflictingDynamicParameters to rename conflicting parameters (e.g., _PSEdition) and add aliases for the original names.
  • Updated Get-MockDynamicParameter to resolve conflicts for Cmdlet and Function parameter sets.
  • Updated Get-ContextToDefine to new logic.
  • Added tests from the linked issue to validate renamed and aliased dynamic parameters. Minor modifications to the tests:
    • replaced Assert-MockCalled with Should -Invoke
    • replaced $PSEdition with $_PSEdition in the ParameterFilter

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

@benjaminfuchs benjaminfuchs force-pushed the fix/resolve-conflicting-dynamic-parameters branch from cb2b3e3 to bff78d7 Compare December 20, 2024 11:28
@nohwnd
Copy link
Member

nohwnd commented Dec 20, 2024

Nice I will have a look on this after holidays when I have enough mental capacity. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock fails to process dynamic parameter called PSEdition
2 participants