File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
tools/AzureRM.BootStrapper Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -1156,6 +1156,20 @@ Describe "Use-AzureRmProfile" {
1156
1156
$useError.exception.message.contains (" A different profile version of module" ) | Should Be $true
1157
1157
}
1158
1158
}
1159
+
1160
+ # User has module2 from profile1 imported; tries to execute Use-AzureRmProfile for profile1 with module1. Should import.
1161
+ Context " A different module from same profile was previously imported" {
1162
+ Mock Get-AzureRmModule - Verifiable { " 1.0" }
1163
+ $VersionObj = New-Object - TypeName System.Version - ArgumentList " 1.0"
1164
+ $moduleObj = New-Object - TypeName PSObject
1165
+ $moduleObj | Add-Member NoteProperty - Name " Name" - Value " Module2"
1166
+ $moduleObj | Add-Member NoteProperty Version($VersionObj )
1167
+ Mock Get-Module - Verifiable { $moduleObj }
1168
+ It " Should import module" {
1169
+ $result = Use-AzureRmProfile - Profile ' Profile1' - Module ' Module1'
1170
+ Assert-MockCalled Import-Module - Times 1
1171
+ }
1172
+ }
1159
1173
}
1160
1174
}
1161
1175
Original file line number Diff line number Diff line change @@ -1043,12 +1043,12 @@ function Use-AzureRmProfile
1043
1043
$importedModules = Get-Module " Azure*"
1044
1044
foreach ($importedModule in $importedModules )
1045
1045
{
1046
- $versions = $ProfileMap .$Profile .$ ($importedModule.Name )
1047
- if ($null -ne $versions )
1046
+ $importedVersions = $ProfileMap .$Profile .$ ($importedModule.Name )
1047
+ if ($null -ne $importedVersions )
1048
1048
{
1049
1049
# We need the latest version in that profile to be imported. If old version was imported, block user and ask to import in a new session
1050
- $version = Get-LatestModuleVersion - versions $versions
1051
- if ([system.version ]$version -ne $importedModule.Version )
1050
+ $importedVersion = Get-LatestModuleVersion - versions $importedVersions
1051
+ if ([system.version ]$importedVersion -ne $importedModule.Version )
1052
1052
{
1053
1053
Write-Error " A different profile version of module $importedModule is imported in this session. Start a new PowerShell session and retry the operation." - Category InvalidOperation
1054
1054
return
You can’t perform that action at this time.
0 commit comments