Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 0 additions & 7 deletions private/Update-QuickPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ function Update-QuickPath {
function Update-QuickPathFromGallery {
try {
$moduleName = "quickpath"
if (Get-Module $moduleName) {
Remove-Module $moduleName -Force -ErrorAction SilentlyContinue
}
Update-Module -Name $moduleName -Force -ErrorAction Stop
Import-Module $moduleName -Force -ErrorAction Stop
Write-Host "$moduleName updated from gallery and reloaded." -ForegroundColor Green
Expand All @@ -37,10 +34,6 @@ function Update-QuickPathFromBuild {
Write-Warning "Built quickpath module not found at '$quickPathManifest'. Please run 'Invoke-Build Build' first."
return
}

if (Get-Module $moduleName) {
Remove-Module $moduleName -Force -ErrorAction SilentlyContinue
}

Import-Module $quickPathManifest -Force -ErrorAction Stop
Write-Host "$moduleName has been built, tested, and reloaded." -ForegroundColor Green
Expand Down
12 changes: 5 additions & 7 deletions tests/Update-QuickPath.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Context 'Update-QuickPath' {
. $PSScriptRoot\..\private\Update-QuickPath.ps1
}
BeforeEach {
Mock Remove-Module
Mock Update-Module
Mock Import-Module
}
Expand Down Expand Up @@ -42,17 +41,16 @@ Context 'Update-QuickPath' {

Assert-MockCalled -CommandName Write-Error -Times 1 -Exactly -Scope It
}
It 'Should remove existing module before updating from gallery' {
Mock Get-Module { @{ Name = "quickpath" } }
It 'Should reload module after updating from gallery' {
Update-QuickPath -FromGallery

Assert-MockCalled -CommandName Remove-Module -ParameterFilter { $Name -eq "quickpath" } -Times 1 -Exactly -Scope It
Assert-MockCalled -CommandName Update-Module -ParameterFilter { $Name -eq "quickpath" } -Times 1 -Exactly -Scope It
Assert-MockCalled -CommandName Import-Module -ParameterFilter { $Name -eq "quickpath" } -Times 1 -Exactly -Scope It
}
It 'Should remove existing module before updating from build' {
Mock Get-Module { @{ Name = "quickpath" } }
It 'Should reload module after updating from build' {
Mock Test-Path { $true }
Update-QuickPathFromBuild

Assert-MockCalled -CommandName Remove-Module -ParameterFilter { $Name -eq "quickpath" } -Times 1 -Exactly -Scope It
Assert-MockCalled -CommandName Import-Module -Times 1 -Exactly -Scope It
}
}