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

46 lines
1.5 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-DynamicAwsRegionParameter" {
Context "Logic" {
Mock -CommandName Get-SupportedAwsRegions -ModuleName $moduleForMock -MockWith { return @(
"mexico-south-55",
"australia-west-99"
)}
It "Uses the Specified Parameter Name" {
$testParamName = "SupaFly"
$param = Get-DynamicAwsRegionParameter -DynamicParameterName $testParamName
$param.Keys | Should -BeExactly $testParamName
}
It "Uses the Specified ParameterSet Name" {
$testParamSetName = "wOne"
$param = Get-DynamicAwsRegionParameter -ParameterSetName $testParamSetName
$param.Values.Attributes.ParameterSetName | Should -BeExactly $testParamSetName
}
It "Is a Mandatory Parameter if Specified" {
$param = Get-DynamicAwsRegionParameter -IsMandatoryParameter
$param.Values.Attributes.Mandatory | Should -BeTrue
}
It "Creates a Validate Set with Valid AWS Profile Names" {
$param = Get-DynamicAwsRegionParameter
$param.Values.Attributes.ValidValues | Should -Be @( "mexico-south-55", "australia-west-99")
}
}
}