Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
11 changes: 8 additions & 3 deletions src/classes/public/Repositories/GitHubCustomProperty.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment thread
MariusStorhaug marked this conversation as resolved.
Comment on lines 10 to +17
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor now branches on whether value is an IEnumerable (excluding string) to preserve multi-select values as arrays, but this behavior isn't covered by a deterministic unit test in tests/. Add a small Pester test that constructs GitHubCustomProperty from a [pscustomobject]@{ property_name = 'X'; value = @('a','b') } and from a scalar string, and asserts the resulting .Value type (and propertyName alias resolution).

Copilot uses AI. Check for mistakes.
}

[string] ToString() {
Expand Down
37 changes: 37 additions & 0 deletions tests/GitHub.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,43 @@
[CmdletBinding()]
param()

Describe 'GitHubCustomProperty' {
It 'Preserves array value for multi-select properties' {
$obj = [PSCustomObject]@{
property_name = 'SubscribeTo'
value = @('Custom Instructions', 'License', 'Prompts')
}
$prop = [GitHubCustomProperty]::new($obj)
$prop.Name | Should -Be 'SubscribeTo'
$prop.Value | Should -BeOfType [string]
$prop.Value | Should -HaveCount 3
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$prop.Value[0] | Should -Be 'Custom Instructions'
$prop.Value[1] | Should -Be 'License'
$prop.Value[2] | Should -Be 'Prompts'
}

It 'Keeps scalar string value as string' {
$obj = [PSCustomObject]@{
property_name = 'Type'
value = 'Module'
}
$prop = [GitHubCustomProperty]::new($obj)
$prop.Name | Should -Be 'Type'
$prop.Value | Should -Be 'Module'
$prop.Value | Should -BeOfType [string]
}

It 'Handles GraphQL-style property names' {
$obj = [PSCustomObject]@{
propertyName = 'Environment'
value = 'production'
}
$prop = [GitHubCustomProperty]::new($obj)
$prop.Name | Should -Be 'Environment'
$prop.Value | Should -Be 'production'
}
}

Describe 'Auth' {
$authCases = . "$PSScriptRoot/Data/AuthCases.ps1"

Expand Down
Loading