ps/Modules/Alkami.DevOps.Common/Public/Get-AlkamiAwsProfileList.tests.ps1
2023-05-30 22:51:22 -07:00

62 lines
1.9 KiB
PowerShell

. $PSScriptRoot\..\..\Load-PesterModules.ps1
Describe "Get-AlkamiAwsProfileList" {
Context "Result Respects TeamCity Process" {
It "Does Not Prepend 'temp-'" {
Mock -CommandName Test-IsTeamCityProcess -ModuleName Alkami.DevOps.Common -MockWith { return $true }
(Get-AlkamiAwsProfileList) | Should -Contain "Prod"
}
It "Calls Test-IsTeamCityProcess" {
Mock -CommandName Test-IsTeamCityProcess -ModuleName Alkami.DevOps.Common -MockWith { return $true }
Get-AlkamiAwsProfileList | Out-Null
Assert-MockCalled -CommandName Test-IsTeamCityProcess -Times 1 -Exactly -Scope It -ModuleName Alkami.DevOps.Common
}
}
Context "Result Respects 'RawOutput' Flag For Non-TeamCity Processes" {
It "Prepends 'temp-' By Default" {
Mock -CommandName Test-IsTeamCityProcess -ModuleName Alkami.DevOps.Common -MockWith { return $false }
( Get-AlkamiAwsProfileList ) | Should -Contain 'temp-prod'
}
It "Does Not Prepend 'temp-' When RawOutput is Specified" {
Mock -CommandName Test-IsTeamCityProcess -ModuleName Alkami.DevOps.Common -MockWith { return $false }
( Get-AlkamiAwsProfileList -RawOutput ) | Should -Contain 'Prod'
}
}
Context "Result Respects 'IncludeSubsidiaries' Flag" {
Mock -CommandName Test-IsTeamCityProcess -ModuleName Alkami.DevOps.Common -MockWith { return $false }
It "Does Not Include AchDev By Default" {
( Get-AlkamiAwsProfileList ) | Should -Not -Contain 'temp-achdev'
}
It "Includes AchDev When IncludeSubsidiaries is Specified" {
( Get-AlkamiAwsProfileList -IncludeSubsidiaries ) | Should -Contain 'temp-achdev'
}
It "Includes AchDev When All is Specified" {
( Get-AlkamiAwsProfileList -All ) | Should -Contain 'temp-achdev'
}
}
}