ps/Modules/Alkami.DevOps.Common/Public/Get-DynamicAwsProfilesParameter.tests.ps1

53 lines
1.9 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
. $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-DynamicAwsProfilesParameter" {
Context "Logic" {
Mock -CommandName Get-AwsCredentialConfiguration -ModuleName $moduleForMock -MockWith { return @(
(New-Object PSObject -Property @{ "Name"="FogoDeChao"; }),
(New-Object PSObject -Property @{ "Name"="12Cuts"; })
)}
It "Uses the Specified Parameter Name" {
$testParamName = "SupaFly"
$param = Get-DynamicAwsProfilesParameter -DynamicParameterName $testParamName
$param.Keys | Should -BeExactly $testParamName
}
It "Uses the Specified ParameterSet Name" {
$testParamSetName = "MisterP"
$param = Get-DynamicAwsProfilesParameter -ParameterSetName $testParamSetName
$param.Values.Attributes.ParameterSetName | Should -BeExactly $testParamSetName
}
It "Is a Mandatory Parameter if Specified" {
$param = Get-DynamicAwsProfilesParameter -IsMandatoryParameter
$param.Values.Attributes.Mandatory | Should -BeTrue
}
It "Creates a Validate Set with Valid AWS Profile Names" {
$param = Get-DynamicAwsProfilesParameter
$param.Values.Attributes.ValidValues | Should -Be @( "FogoDeChao", "12Cuts")
}
It "Returns a Single Invalid Parameter if None Can be Read from Local Configuration" {
Mock -CommandName Get-AwsCredentialConfiguration -ModuleName $moduleForMock -MockWith { return $null }
$param = Get-DynamicAwsProfilesParameter
$param.Values.Attributes.ValidValues | Should -Be @( "NoLocalProfilesFound" )
}
}
}