Skip to content

Commit ffa1c00

Browse files
Replace mocked GitHubCustomProperty unit tests with API integration test
Removed fabricated [PSCustomObject] tests from GitHub.Tests.ps1 and added a real integration test in Repositories.Tests.ps1 that calls Get-GitHubRepositoryCustomProperty against org repositories and validates that multi-select values are preserved as [string[]] arrays.
1 parent 9b8a0af commit ffa1c00

2 files changed

Lines changed: 17 additions & 38 deletions

File tree

tests/GitHub.Tests.ps1

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,6 @@
1919
[CmdletBinding()]
2020
param()
2121

22-
Describe 'GitHubCustomProperty' {
23-
It 'Preserves array value for multi-select properties' {
24-
$obj = [PSCustomObject]@{
25-
property_name = 'SubscribeTo'
26-
value = @('Custom Instructions', 'License', 'Prompts')
27-
}
28-
$prop = [GitHubCustomProperty]::new($obj)
29-
$prop.Name | Should -Be 'SubscribeTo'
30-
$prop.Value -is [string[]] | Should -BeTrue -Because 'multi-select values must be preserved as string arrays'
31-
$prop.Value | Should -HaveCount 3
32-
$prop.Value[0] | Should -Be 'Custom Instructions'
33-
$prop.Value[1] | Should -Be 'License'
34-
$prop.Value[2] | Should -Be 'Prompts'
35-
}
36-
37-
It 'Keeps scalar string value as string' {
38-
$obj = [PSCustomObject]@{
39-
property_name = 'Type'
40-
value = 'Module'
41-
}
42-
$prop = [GitHubCustomProperty]::new($obj)
43-
$prop.Name | Should -Be 'Type'
44-
$prop.Value | Should -Be 'Module'
45-
$prop.Value | Should -BeOfType [string]
46-
}
47-
48-
It 'Handles GraphQL-style property names' {
49-
$obj = [PSCustomObject]@{
50-
propertyName = 'Environment'
51-
value = 'production'
52-
}
53-
$prop = [GitHubCustomProperty]::new($obj)
54-
$prop.Name | Should -Be 'Environment'
55-
$prop.Value | Should -Be 'production'
56-
}
57-
}
58-
5922
Describe 'Auth' {
6023
$authCases = . "$PSScriptRoot/Data/AuthCases.ps1"
6124

@@ -330,7 +293,7 @@ Describe 'GitHub' {
330293
$stamps.Count | Should -BeGreaterThan 0
331294
}
332295
It 'Get-GitHubStamp - Each stamp has Name and BaseUrl properties' {
333-
LogGroup "Stamps - Details" {
296+
LogGroup 'Stamps - Details' {
334297
Get-GitHubStamp | ForEach-Object {
335298
Write-Host ($_ | Format-List | Out-String)
336299
$_.Name | Should -Not -BeNullOrEmpty

tests/Repositories.Tests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,22 @@ Describe 'Repositories' {
518518
}
519519
$repos.Count | Should -BeGreaterThan 0
520520
}
521+
It 'Get-GitHubRepositoryCustomProperty - Gets custom properties and preserves value types' -Skip:($OwnerType -ne 'organization') {
522+
LogGroup 'Custom Properties' {
523+
$properties = Get-GitHubRepositoryCustomProperty -Owner $owner -Repository $repoName
524+
Write-Host ($properties | Format-List | Out-String)
525+
}
526+
if ($properties) {
527+
foreach ($prop in $properties) {
528+
$prop.Name | Should -Not -BeNullOrEmpty
529+
if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) {
530+
$prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)"
531+
} else {
532+
$prop.Value | Should -BeOfType [string]
533+
}
534+
}
535+
}
536+
}
521537
It 'Set-GitHubRepository - Updates an existing repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
522538
$description = 'Updated description'
523539
LogGroup 'Repository - Set update' {

0 commit comments

Comments
 (0)