ps/Modules/Alkami.PowerShell.Common/Public/Test-PathIsInApprovedPackageLocation.tests.ps1

32 lines
1.1 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
. $PSScriptRoot\..\..\Load-PesterModules.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.'
$functionPath = Join-Path -Path $here -ChildPath $sut
Write-Host "Overriding SUT: $functionPath"
Import-Module $functionPath -Force
$moduleForMock = ""
Describe "Test-PathIsInApprovedPackageLocation" {
Context "Testing bad paths" {
It "Return false when C:\Program Files is given" {
Test-PathIsInApprovedPackageLocation -SourcePath ("C:\Program Files\") | Should Be $false
}
}
Context "Testing good paths" {
It "Returns true when a good path is given" {
Test-PathIsInApprovedPackageLocation -SourcePath (Join-Path (Get-ChocolateyInstallPath) "lib\Alkami.PowerShell.IIS") | Should Be $true
}
}
Context "When an indeterminate path is given returns false" {
It "Returns false for Get-ChocolateyInstallPath" {
Test-PathIsInApprovedPackageLocation -SourcePath (Get-ChocolateyInstallPath) | Should Be $false
}
}
}
#endregion Test-IsNull