Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix logic and typos.
  • Loading branch information
sethvs committed Jul 24, 2018
commit 321537c6e52b24e9187afd267bb0b18b242bbed3
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ internal static Exception ModuleSpecificationInitHelper(ModuleSpecification modu
return new ArgumentException(message);
}

if (moduleSpecification.Version > ModuleCmdletBase.GetMaximumVersion(moduleSpecification.MaximumVersion))
if (moduleSpecification.Version != null && moduleSpecification.MaximumVersion != null &&
moduleSpecification.Version > ModuleCmdletBase.GetMaximumVersion(moduleSpecification.MaximumVersion))
{
message = StringUtil.Format(Modules.ModuleSpecificationMemberIsLessThanOther, "MaximumVersion", "Version");
message = StringUtil.Format(Modules.ModuleSpecificationMemberIsLessThanOther, "MaximumVersion", "ModuleVersion");
return new ArgumentException(message);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Describe "Import-Module" -Tags "CI" {
}

It "should throw if 'MaximumVersion' is less than 'Version' when using -FullyQualifiedName parameter" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In addition to this test, we should add a more specific one using the [ModuleSpecification] constructor.

You should find those tests here (I know that's not an obvious place at all).

Note to self: once #7499 is merged, this test will be included in that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

{ Import-Module -FullyQualifiedName @{ModuleName = $moduleName; Version = '2.0'; MaximumVersion = '1.0'} } | Should -Throw -ExceptionType 'System.Management.Automation.ParameterBindingException'
{ Import-Module -FullyQualifiedName @{ModuleName = $moduleName; ModuleVersion = '2.0'; MaximumVersion = '1.0'} } | Should -Throw -ExceptionType 'System.Management.Automation.ParameterBindingException'
}
}

Expand Down