Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Public/Array/Get-PfbArraySpace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function Get-PfbArraySpace {
.PARAMETER Array
The FlashBlade connection object. If not specified, uses the default connection.
.PARAMETER Type
Filter by space type (e.g., 'array', 'file-system', 'object-store').
Filter by space type. Valid values: 'array', 'file-system', 'object-store'.
Defaults to 'array' if not specified.
.EXAMPLE
Get-PfbArraySpace
#>
Expand All @@ -17,6 +18,7 @@ function Get-PfbArraySpace {
[PSCustomObject]$Array,

[Parameter()]
[ValidateSet('array', 'file-system', 'object-store')]
[string]$Type
)

Expand Down
39 changes: 39 additions & 0 deletions Tests/Get-PfbArraySpace.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.0' }

BeforeAll {
Import-Module "$PSScriptRoot/../PureStorageFlashBladePowerShell.psd1" -Force
$script:fakeArray = [PSCustomObject]@{ Endpoint = 'fb.example.test'; ApiVersion = '2.0'; AuthToken = 'x' }
}

Describe 'Get-PfbArraySpace' {
BeforeEach {
Mock -ModuleName PureStorageFlashBladePowerShell Assert-PfbConnection { }
Mock -ModuleName PureStorageFlashBladePowerShell Invoke-PfbApiRequest { }
}

It 'restricts -Type to the three real spec-documented values' {
$attr = (Get-Command Get-PfbArraySpace).Parameters['Type'].Attributes |
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] }
$attr | Should -Not -BeNullOrEmpty
$attr.ValidValues | Should -Be @('array', 'file-system', 'object-store')
}

It 'rejects an invalid -Type value before making any API call' {
{ Get-PfbArraySpace -Type 'bogus' -Array $fakeArray } | Should -Throw
Should -Invoke Invoke-PfbApiRequest -ModuleName PureStorageFlashBladePowerShell -Times 0 -Exactly
}

It 'passes a valid -Type through to the query string' {
Get-PfbArraySpace -Type 'file-system' -Array $fakeArray
Should -Invoke Invoke-PfbApiRequest -ModuleName PureStorageFlashBladePowerShell -Times 1 -Exactly -ParameterFilter {
$Method -eq 'GET' -and $Endpoint -eq 'arrays/space' -and $QueryParams['type'] -eq 'file-system'
}
}

It 'omits -Type from the query string when not specified (server defaults to array)' {
Get-PfbArraySpace -Array $fakeArray
Should -Invoke Invoke-PfbApiRequest -ModuleName PureStorageFlashBladePowerShell -Times 1 -Exactly -ParameterFilter {
-not $QueryParams.ContainsKey('type')
}
}
}
Loading