Skip to content

Mock Set-PSRepository throws ParameterBindingValidationException on not existing parameter 'Location' #619

Open
@StefanSchoof

Description

@StefanSchoof

I try to mock Set-PSRepository

Describe "SetPSRepository" {
    Mock Set-PSRepository

    It "Should work" {
        Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted"
    }
}

If I run this I get:

 [-] Should work 273ms
   ValidationMetadataException: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   ParameterBindingValidationException: Cannot validate argument on parameter 'Location'. The argument is null or empty.
 Provide an argument that is not null or empty, and then try the command again.
   CmdletInvocationException: Cannot validate argument on parameter 'Location'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   ParameterBindingException: Cannot retrieve the dynamic parameters for the cmdlet. Cannot validate argument on parameter 'Location'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   at <ScriptBlock>,\SetPSRepository.Tests.ps1:
 line 5

The Set-PSRepository has no Location parameter. Why is there a Location in the stack trace?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions