40 lines
1.8 KiB
PowerShell
40 lines
1.8 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 "Test-IsOverflowServer" {
|
||
|
|
||
|
Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { }
|
||
|
Mock -ModuleName $moduleForMock -CommandName Test-IsAws -MockWith { return $true }
|
||
|
Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { return "[UUT]" }
|
||
|
|
||
|
Context "Successfull call of Get-CurrentInstanceTags" {
|
||
|
|
||
|
It "Returns `$true for Overflow Tag on Overflow server" {
|
||
|
Mock -ModuleName $moduleForMock -CommandName Get-CurrentInstanceTags -MockWith { return "true" }
|
||
|
Test-IsOverflowServer | Should Be $true
|
||
|
Assert-MockCalled -ModuleName $inScopeModuleForAssert -CommandName Get-CurrentInstanceTags -Times 1 -Exactly -Scope It
|
||
|
}
|
||
|
|
||
|
It "Returns `$false for Overflow Tag on a non-Overflow server" {
|
||
|
Mock -ModuleName $moduleForMock -CommandName Get-CurrentInstanceTags -MockWith { return }
|
||
|
Test-IsOverflowServer | Should Be $false
|
||
|
Assert-MockCalled -ModuleName $inScopeModuleForAssert -CommandName Get-CurrentInstanceTags -Times 1 -Exactly -Scope It
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Context "Failed call of Get-CurrentInstanceTags" {
|
||
|
|
||
|
It "Calls Write-Warning when failling to retrieve tags" {
|
||
|
Mock -ModuleName $moduleForMock -CommandName Get-CurrentInstanceTags -MockWith { throw "Generic Error" }
|
||
|
Test-IsOverflowServer
|
||
|
Assert-MockCalled -ModuleName $inScopeModuleForAssert -CommandName Write-Warning -Times 1 -Exactly -Scope It
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|