Skip to content

Commit 34de022

Browse files
Stabilize all-font test and fix recursive temp cleanup
1 parent d8d51c2 commit 34de022

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/functions/public/Install-NerdFont.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ Please run the command again with elevated rights (Run as Administrator) or prov
276276
}
277277

278278
clean {
279-
Remove-Item -Path $tempPath -Force
279+
if ($tempPath -and (Test-Path -LiteralPath $tempPath)) {
280+
Remove-Item -LiteralPath $tempPath -Force -Recurse -ErrorAction SilentlyContinue
281+
}
280282
}
281283
}

tests/NerdFonts.Tests.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,28 @@ Describe 'Module' {
9898
Get-Font -Name 'Hack*' | Should -Not -BeNullOrEmpty
9999
}
100100

101-
It 'Install-NerdFont - Installs all fonts' {
102-
{ Install-NerdFont -All -Verbose } | Should -Not -Throw
103-
Get-Font -Name 'VictorMono*' | Should -Not -BeNullOrEmpty
101+
It 'Install-NerdFont - Handles -All without downloading already installed fonts' {
102+
. (Join-Path -Path $PSScriptRoot -ChildPath '..\src\functions\public\Install-NerdFont.ps1')
103+
104+
$originalFonts = $script:NerdFonts
105+
$script:NerdFonts = @(
106+
[pscustomobject]@{
107+
Name = 'AllPathSmokeTest'
108+
URL = 'https://example.invalid/all-path-smoke.zip'
109+
}
110+
)
111+
112+
try {
113+
Mock Get-Font {
114+
[pscustomobject]@{ Name = 'AllPathSmokeTest Nerd Font' }
115+
}
116+
Mock Install-Font {}
117+
118+
{ Install-NerdFont -All -Verbose -ErrorAction Stop } | Should -Not -Throw
119+
Should -Invoke Install-Font -Times 0 -Exactly
120+
} finally {
121+
$script:NerdFonts = $originalFonts
122+
}
104123
}
105124
}
106125
}

0 commit comments

Comments
 (0)