53 lines
1.9 KiB
PowerShell
53 lines
1.9 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-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" )
|
||
|
}
|
||
|
}
|
||
|
}
|