ps/Modules/Alkami.DevOps.Installation/Public/Get-NewRelicYamlPath.tests.ps1

37 lines
1.2 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 "Get-NewRelicYamlPath" {
Mock -CommandName Get-LogLeadName -MockWith {}
Mock -CommandName Test-Path -MockWith { $true }
Context "Validation" {
It "Finds the yaml" {
Mock -CommandName Write-Warning -MockWith {}
Get-NewRelicYamlPath | Should -Be "C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml"
}
It "When a yaml file is not found, It writes a warning" {
Mock -CommandName Test-Path -MockWith { $false }
Get-NewRelicYamlPath
Assert-MockCalled -CommandName Write-Warning -Scope Context -ParameterFilter { $Message -like "*File does not exist:*" }
}
It "Returns null" {
Mock -CommandName Write-Warning -MockWith {}
Mock -CommandName Test-Path -MockWith { $false }
Get-NewRelicYamlPath | Should -Be $null
}
}
}