Skip to content

Commit

Permalink
🐛 Best Candidate comparison by ref not matching correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinGrote authored Jan 3, 2024
1 parent 7211e53 commit 6fe4e90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ModuleFast.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ function Find-LocalModule {
if ($Update -and ($ModuleSpec.Max -ne $candidateVersion)) {
Write-Debug "${ModuleSpec}: Skipping $candidateVersion because -Update was specified and the version does not exactly meet the upper bound of the spec or no upper bound was specified at all, meaning there is a possible newer version remotely."
#We can use this ref later to find out if our best remote version matches what is installed without having to read the manifest again
if ($BestCandidate -and $manifestCandidate.ModuleVersion -gt $bestCandidate.Value[$moduleSpec]) {
if ($bestCandidate.Value[$moduleSpec] -and $manifestCandidate.ModuleVersion -gt $bestCandidate.Value[$moduleSpec]) {
Write-Debug "${ModuleSpec}: New Best Candidate Version $($manifestCandidate.ModuleVersion)"
$BestCandidate.Value.Add($moduleSpec, $manifestCandidate)
}
Expand Down
6 changes: 6 additions & 0 deletions ModuleFast.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ Describe 'Install-ModuleFast' -Tag 'E2E' {
Install-ModuleFast @imfParams 'Az.Compute', 'Az.CosmosDB' -Update -Plan
| Should -BeNullOrEmpty
}
It 'Updates if multiple local versions installed' {
Install-ModuleFast @imfParams 'Plaster=1.1.1'
Install-ModuleFast @imfParams 'Plaster=1.1.3'
$actual = Install-ModuleFast @imfParams 'Plaster' -Update -PassThru
$actual.ModuleVersion | Should -Be '1.1.4'
}

It 'Updates only dependent module that requires update' {
Install-ModuleFast @imfParams @{ ModuleName = 'Az.Accounts'; RequiredVersion = '2.10.2' }
Expand Down

0 comments on commit 6fe4e90

Please sign in to comment.