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

Use TestDrive in Pester.PSGetModuleHelp.Tests.ps1 #370

Merged
merged 1 commit into from
Nov 27, 2018
Merged
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
22 changes: 8 additions & 14 deletions Tests/Pester.PSGetModuleHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ $script:FullyQualifiedModuleName = [Microsoft.PowerShell.Commands.ModuleSpecific
}

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

function GetFiles {
param (
Expand All @@ -37,14 +36,6 @@ function GetFiles {
}

Describe 'Validate PowerShellGet module help' -tags 'P1', 'OuterLoop' {
BeforeAll {
$null = New-Item -Path $script:SaveHelpPath -ItemType Directory -Force
}

AfterAll {
Remove-Item -Path $script:SaveHelpPath -Force -Recurse
}

It 'Validate Update-Help for the PowerShellGet module' {
$UpdateHelp_Params = @{
Force = $true
Expand Down Expand Up @@ -72,18 +63,21 @@ Describe 'Validate PowerShellGet module help' -tags 'P1', 'OuterLoop' {
$FindModuleCommandHelp.Examples | Should Not BeNullOrEmpty
}

$helpPath = Join-Path -Path $TestDrive -ChildPath PSGetHelp
New-Item -Path $helpPath -ItemType Directory

It 'Validate Save-Help for the PowerShellGet module' {
if($PSVersionTable.PSVersion -gt '4.0.0') {
Save-Help -FullyQualifiedModule $script:FullyQualifiedModuleName -Force -UICulture en-US -DestinationPath $script:SaveHelpPath
Save-Help -FullyQualifiedModule $script:FullyQualifiedModuleName -Force -UICulture en-US -DestinationPath $helpPath
}
else {
Save-Help -Module PowerShellGet -Force -UICulture en-US -DestinationPath $script:SaveHelpPath
Save-Help -Module PowerShellGet -Force -UICulture en-US -DestinationPath $helpPath
}

$compressedFile = GetFiles -Include "*$script:HelpContentExtension" -Path $script:SaveHelpPath | ForEach-Object {Split-Path -Path $_ -Leaf}
$compressedFile = GetFiles -Include "*$script:HelpContentExtension" -Path $helpPath | ForEach-Object { Split-Path -Path $_ -Leaf }
$compressedFile | Should Be $script:ExpectedCompressedFile
$helpFilesSaved = GetFiles -Include "*HelpInfo.xml" -Path $script:SaveHelpPath | ForEach-Object {Split-Path -Path $_ -Leaf}

$helpFilesSaved = GetFiles -Include "*HelpInfo.xml" -Path $helpPath | ForEach-Object { Split-Path -Path $_ -Leaf }
$helpFilesSaved | Should Be $script:ExpectedHelpInfoFile
}
}