Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 2235b61

Browse files
matt9uccialerickson
authored andcommitted
Use TestDrive in Pester.PSGetModuleHelp.Tests.ps1 (#370)
1 parent 2692b18 commit 2235b61

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

Tests/Pester.PSGetModuleHelp.Tests.ps1

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ $script:FullyQualifiedModuleName = [Microsoft.PowerShell.Commands.ModuleSpecific
2020
}
2121

2222
$script:HelpInstallationPath = Join-Path -Path $script:PowerShellGetModuleInfo.ModuleBase -ChildPath 'en-US'
23-
$script:SaveHelpPath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath "PSGetHelp_$(Get-Random)"
2423

2524
function GetFiles {
2625
param (
@@ -37,14 +36,6 @@ function GetFiles {
3736
}
3837

3938
Describe 'Validate PowerShellGet module help' -tags 'P1', 'OuterLoop' {
40-
BeforeAll {
41-
$null = New-Item -Path $script:SaveHelpPath -ItemType Directory -Force
42-
}
43-
44-
AfterAll {
45-
Remove-Item -Path $script:SaveHelpPath -Force -Recurse
46-
}
47-
4839
It 'Validate Update-Help for the PowerShellGet module' {
4940
$UpdateHelp_Params = @{
5041
Force = $true
@@ -72,18 +63,21 @@ Describe 'Validate PowerShellGet module help' -tags 'P1', 'OuterLoop' {
7263
$FindModuleCommandHelp.Examples | Should Not BeNullOrEmpty
7364
}
7465

66+
$helpPath = Join-Path -Path $TestDrive -ChildPath PSGetHelp
67+
New-Item -Path $helpPath -ItemType Directory
68+
7569
It 'Validate Save-Help for the PowerShellGet module' {
7670
if($PSVersionTable.PSVersion -gt '4.0.0') {
77-
Save-Help -FullyQualifiedModule $script:FullyQualifiedModuleName -Force -UICulture en-US -DestinationPath $script:SaveHelpPath
71+
Save-Help -FullyQualifiedModule $script:FullyQualifiedModuleName -Force -UICulture en-US -DestinationPath $helpPath
7872
}
7973
else {
80-
Save-Help -Module PowerShellGet -Force -UICulture en-US -DestinationPath $script:SaveHelpPath
74+
Save-Help -Module PowerShellGet -Force -UICulture en-US -DestinationPath $helpPath
8175
}
8276

83-
$compressedFile = GetFiles -Include "*$script:HelpContentExtension" -Path $script:SaveHelpPath | ForEach-Object {Split-Path -Path $_ -Leaf}
77+
$compressedFile = GetFiles -Include "*$script:HelpContentExtension" -Path $helpPath | ForEach-Object { Split-Path -Path $_ -Leaf }
8478
$compressedFile | Should Be $script:ExpectedCompressedFile
85-
86-
$helpFilesSaved = GetFiles -Include "*HelpInfo.xml" -Path $script:SaveHelpPath | ForEach-Object {Split-Path -Path $_ -Leaf}
79+
80+
$helpFilesSaved = GetFiles -Include "*HelpInfo.xml" -Path $helpPath | ForEach-Object { Split-Path -Path $_ -Leaf }
8781
$helpFilesSaved | Should Be $script:ExpectedHelpInfoFile
8882
}
8983
}

0 commit comments

Comments
 (0)