82 lines
3.0 KiB
PowerShell
82 lines
3.0 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-IsDeveloperMachine" {
|
|
|
|
Mock Select-AlkamiTeaServers -ModuleName $moduleForMock -MockWith {}
|
|
Mock Select-AlkamiAppServers -ModuleName $moduleForMock -MockWith {}
|
|
Mock Select-AlkamiMicServers -ModuleName $moduleForMock -MockWith {}
|
|
Mock Select-AlkamiWebServers -ModuleName $moduleForMock -MockWith {}
|
|
|
|
Context "testing production configuration with global constant" {
|
|
It "Returns false for Environment.Type QA" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return "QA" }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $false
|
|
}
|
|
}
|
|
|
|
Context "testing production configuration with random string" {
|
|
It "Returns false for Environment.Type production" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return "Production" }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $false
|
|
}
|
|
}
|
|
|
|
<# ********************* #>
|
|
|
|
Context "testing empty or developer configurations" {
|
|
|
|
It "Returns true for Environment.Type Developer" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return 'Development' }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $true
|
|
}
|
|
|
|
It "Returns true for Environment.Type empty string" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return "" }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $true
|
|
}
|
|
|
|
It "Returns true for Environment.Type null" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return $null }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $true
|
|
}
|
|
|
|
It "Returns false for APP tier server in AWS Dev account" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return $null }
|
|
Mock -CommandName Select-AlkamiAppServers -ModuleName $moduleForMock -MockWith { $true }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $false
|
|
}
|
|
|
|
It "Returns false for MIC tier server in AWS Dev account" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return $null }
|
|
Mock -CommandName Select-AlkamiMicServers -ModuleName $moduleForMock -MockWith { $true }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $false
|
|
}
|
|
|
|
It "Returns false for WEB tier server in AWS Dev account" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return $null }
|
|
Mock -CommandName Select-AlkamiWebServers -ModuleName $moduleForMock -MockWith { $true }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $false
|
|
}
|
|
|
|
It "Returns false for TEA tier server in AWS Dev account" {
|
|
Mock -CommandName Get-EnvironmentType -ModuleName $moduleForMock -MockWith { return $null }
|
|
Mock -CommandName Select-AlkamiTeaServers -ModuleName $moduleForMock -MockWith { $true }
|
|
|
|
Test-IsDeveloperMachine | Should -Be $false
|
|
}
|
|
}
|
|
} |