37 lines
1.2 KiB
PowerShell
37 lines
1.2 KiB
PowerShell
. $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
|
|
}
|
|
}
|
|
} |