ps/Modules/Alkami.PowerShell.Configuration/Public/Test-IsAppServer.tests.ps1
2023-05-30 22:51:22 -07:00

96 lines
4.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 "Test-IsAppServer" {
Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { return "[UUT]" }
Context "Parameter is passed" {
It "Returns true if passed an app server name" {
Test-IsAppServer -ComputerName "APP123456" | Should -BeTrue
}
It "Returns false if passed a web server name" {
Test-IsAppServer -ComputerName "WEB123456" | Should -BeFalse
}
It "Returns false if passed a mic server name" {
Test-IsAppServer -ComputerName "MIC123456" | Should -BeFalse
}
It "Returns false if passed a dell laptop name" {
Test-IsAppServer -ComputerName "ALK-DELL1234" | Should -BeFalse
}
}
Context "Uses empty ComputerName parameter, delivers right result" {
It "Returns true if UUT has an app server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "APP123456"}
Test-IsAppServer -ComputerName "" | Should -BeTrue
}
It "Returns false if UUT has a web server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "WEB123456"}
Test-IsAppServer -ComputerName "" | Should -BeFalse
}
It "Returns false if UUT has a mic server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "MIC123456"}
Test-IsAppServer -ComputerName "" | Should -BeFalse
}
It "Returns false if UUT has a dell laptop name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "ALK-DELL1234"}
Test-IsAppServer -ComputerName "" | Should -BeFalse
}
}
Context "Uses null ComputerName parameter, delivers right result" {
It "Returns true if UUT has an app server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "APP123456"}
Test-IsAppServer -ComputerName $null | Should -BeTrue
}
It "Returns false if UUT has a web server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "WEB123456"}
Test-IsAppServer -ComputerName $null | Should -BeFalse
}
It "Returns false if UUT has a mic server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "MIC123456"}
Test-IsAppServer -ComputerName $null | Should -BeFalse
}
It "Returns false if UUT has a dell laptop name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "ALK-DELL1234"}
Test-IsAppServer -ComputerName $null | Should -BeFalse
}
}
Context "Uses no ComputerName parameter, delivers right result" {
It "Returns true if UUT has an app server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "APP123456"}
Test-IsAppServer | Should -BeTrue
}
It "Returns false if UUT has a web server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "WEB123456"}
Test-IsAppServer | Should -BeFalse
}
It "Returns false if UUT has a mic server name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "MIC123456"}
Test-IsAppServer | Should -BeFalse
}
It "Returns false if UUT has a dell laptop name" {
Mock -ModuleName $moduleForMock -CommandName Get-FullyQualifiedServerName -MockWith { return "ALK-DELL1234"}
Test-IsAppServer | Should -BeFalse
}
}
}