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 default Data-value in Invoke-File #1852

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

fflaten
Copy link
Collaborator

@fflaten fflaten commented Mar 2, 2021

PR Summary

Using ParameterAttribute or CmdLetBinding in a parameterized testfile causes ParameterBindingException for a $null-value when invoked without providing any parameter-values. $Data-parameter is default null in Invoke-File, but is always passed to the scriptblock. This throws the error since advanced functions (testfile) don't implicitly allow arguments.

PR changes $Data to be empty hashtable by default as splatting the empty hashtable will avoid the error while not affecting the script/testfile. Similar to #1730 for Mocks and #1812 for InModuleScope.

Fix #1851

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)

@nohwnd nohwnd merged commit 5ae134e into pester:v5.0 Mar 4, 2021
@fflaten fflaten deleted the fix-nullexception-1851 branch March 4, 2021 21:17
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.

Exception when using ParameterSetName in Pester
2 participants