-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Throw error message when MaxumimVersion is less than Version when using Import-Module cmdlet with -FullyQualifiedName parameter. #7347
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
Changes from 2 commits
4d0da14
321537c
9b27ae8
77241e1
fdfe12e
3f4d778
1a784a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,9 @@ | |
| <data name="InvalidModuleSpecificationMember" xml:space="preserve"> | ||
| <value>The hashtable describing a module contains one or more members that are not valid. The valid members are ({0}). Remove the members that are not valid ({1}), then try again.</value> | ||
| </data> | ||
| <data name="ModuleSpecificationMemberIsLessThanOther" xml:space="preserve"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message should ideally be slightly more specific. Something like:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| <value>The member '{0}' cannot be less than '{1}'.</value> | ||
| </data> | ||
| <data name="ModuleTooDeeplyNested" xml:space="preserve"> | ||
| <value>Cannot load the module '{0}' because the module nesting limit has been exceeded. Modules can only be nested to {1} levels. Evaluate and change the order in which you are loading modules to prevent exceeding the nesting limit, and then try running your script again.</value> | ||
| </data> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,10 @@ Describe "Import-Module" -Tags "CI" { | |
| Import-Module TestModule -RequiredVersion 1.1 | ||
| (Get-Module TestModule).Version | Should -BeIn "1.1" | ||
| } | ||
|
|
||
| It "should throw if 'MaximumVersion' is less than 'Version' when using -FullyQualifiedName parameter" { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me know if you need any help on creating that test btw, I'm always happy to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| { Import-Module -FullyQualifiedName @{ModuleName = $moduleName; ModuleVersion = '2.0'; MaximumVersion = '1.0'} } | Should -Throw -ExceptionType 'System.Management.Automation.ParameterBindingException' | ||
| } | ||
| } | ||
|
|
||
| Describe "Import-Module with ScriptsToProcess" -Tags "CI" { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add to PR Summary:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should use
$"{nameof(...)}"for the bad membersThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nameof(badKeys) returns 'badKeys', but we need its actual value.
Or am I missing something?