ps/Modules/Alkami.PowerShell.Configuration/Public/Get-ConfigurationFiles.tests.ps1

50 lines
1.7 KiB
PowerShell
Raw Permalink 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 = ""
#region Get-ConfigurationFiles
Describe "Get-ConfigurationFiles" {
# Temp file to write content to
$tempFile = [System.IO.Path]::GetTempFileName()
$tempPath = $tempFile.Split(".") | Select-Object -First 1
New-Item -ItemType Directory $tempPath -ErrorAction SilentlyContinue | Out-Null
$tempOrb = ($tempPath + "\ORB")
if (!(Test-Path $tempOrb))
{
New-Item -ItemType Directory $tempOrb | Out-Null
}
Write-Warning ("Using temp path: $tempOrb for tests")
# Make Directories for Tests
$bankServiceDirectory = New-Item -ItemType Directory ($tempOrb + "\BankService")
$coreServiceDirectory = New-Item -ItemType Directory ($tempOrb + "\CoreService")
# Make Files for Tests
"" | Out-File (Join-Path $bankServiceDirectory "new.web.config")
"" | Out-File (Join-Path $bankServiceDirectory "web.config")
"" | Out-File (Join-Path $coreServiceDirectory "new.web.config")
"" | Out-File (Join-Path $coreServiceDirectory "web.config")
It "Filters temporary files from the build by default" {
$testResults = Get-ConfigurationFiles $tempOrb
($testResults | Where-Object {$_ -match "new\."}).Count | Should Be 0
}
It "Includes only tepmorary files from the build when specified" {
$testResults = Get-ConfigurationFiles $tempOrb $true
($testResults | Where-Object {$_ -match "new\."}).Count | Should Be 2
}
}
#endregion Get-ConfigurationFiles