diff --git a/src/classes/public/Repositories/GitHubCustomProperty.ps1 b/src/classes/public/Repositories/GitHubCustomProperty.ps1 index e00f7e4d0..12ec3b533 100644 --- a/src/classes/public/Repositories/GitHubCustomProperty.ps1 +++ b/src/classes/public/Repositories/GitHubCustomProperty.ps1 @@ -2,14 +2,19 @@ class GitHubCustomProperty { # The name of the custom property. [string] $Name - # The value of the custom property. - [string] $Value + # The value of the custom property. Can be a string or an array of strings for multi-select properties. + [object] $Value GitHubCustomProperty() {} GitHubCustomProperty([PSCustomObject] $Object) { $this.Name = $Object.property_name ?? $Object.propertyName ?? $Object.Name - $this.Value = $Object.value ?? $Object.Value + $rawValue = $Object.value ?? $Object.Value + if ($rawValue -is [System.Collections.IEnumerable] -and $rawValue -isnot [string]) { + $this.Value = [string[]]$rawValue + } else { + $this.Value = $rawValue + } } [string] ToString() { diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index dab477d5a..96f68ff8f 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -293,7 +293,7 @@ Describe 'GitHub' { $stamps.Count | Should -BeGreaterThan 0 } It 'Get-GitHubStamp - Each stamp has Name and BaseUrl properties' { - LogGroup "Stamps - Details" { + LogGroup 'Stamps - Details' { Get-GitHubStamp | ForEach-Object { Write-Host ($_ | Format-List | Out-String) $_.Name | Should -Not -BeNullOrEmpty diff --git a/tests/Repositories.Tests.ps1 b/tests/Repositories.Tests.ps1 index ed482b054..c410e1f26 100644 --- a/tests/Repositories.Tests.ps1 +++ b/tests/Repositories.Tests.ps1 @@ -518,6 +518,22 @@ Describe 'Repositories' { } $repos.Count | Should -BeGreaterThan 0 } + It 'Get-GitHubRepositoryCustomProperty - Gets custom properties and preserves value types' -Skip:($OwnerType -ne 'organization') { + LogGroup 'Custom Properties' { + $properties = Get-GitHubRepositoryCustomProperty -Owner $owner -Repository $repoName + Write-Host ($properties | Format-List | Out-String) + } + if ($properties) { + foreach ($prop in $properties) { + $prop.Name | Should -Not -BeNullOrEmpty + if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) { + $prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)" + } else { + $prop.Value | Should -BeOfType [string] + } + } + } + } It 'Set-GitHubRepository - Updates an existing repository' -Skip:($OwnerType -in ('repository', 'enterprise')) { $description = 'Updated description' LogGroup 'Repository - Set update' {