Skip to content

Commit e66d934

Browse files
🪲 [Fix]: Fixing the Secrets test for PublicKey for codespaces (#518)
## Description This pull request updates the `Secrets.Tests.ps1` test suite to improve how the `Get-GitHubPublicKey` command is tested for different organization plans and makes a minor formatting change to a log message. Test logic improvements for organization plan handling: * Updated the `Get-GitHubPublicKey -Type codespaces` test to conditionally expect a throw for organizations on the 'free' plan, and to run the usual public key retrieval for other plans. This ensures the test behaves correctly based on the organization's plan type. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 002492b commit e66d934

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tests/Secrets.Tests.ps1

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Describe 'Secrets' {
111111

112112
It 'Get-GitHubPublicKey - Codespaces' {
113113
$result = Get-GitHubPublicKey -Type codespaces
114-
LogGroup 'PublicKey - Codespaces' {
114+
LogGroup 'PublicKey' {
115115
Write-Host "$($result | Select-Object * | Format-Table -AutoSize | Out-String)"
116116
}
117117
$result | Should -Not -BeNullOrEmpty
@@ -140,13 +140,21 @@ Describe 'Secrets' {
140140
}
141141

142142
It 'Get-GitHubPublicKey - Codespaces' {
143-
$plan = $org.plan.name
144-
Write-Host "Running with plan [$plan]"
145-
$result = Get-GitHubPublicKey @scope -Type codespaces
146-
LogGroup 'PublicKey' {
147-
Write-Host "$($result | Select-Object * | Format-Table -AutoSize | Out-String)"
143+
LogGroup 'Plan' {
144+
Write-Host "$($org.plan | Select-Object * | Out-String)"
145+
}
146+
switch ($org.plan.name) {
147+
'free' {
148+
{ Get-GitHubPublicKey @scope -Type codespaces } | Should -Throw
149+
}
150+
default {
151+
$result = Get-GitHubPublicKey @scope -Type codespaces
152+
LogGroup 'PublicKey - Codespaces' {
153+
Write-Host "$($result | Select-Object * | Format-Table -AutoSize | Out-String)"
154+
}
155+
$result | Should -Not -BeNullOrEmpty
156+
}
148157
}
149-
$result | Should -Not -BeNullOrEmpty
150158
}
151159
}
152160

@@ -586,7 +594,7 @@ Describe 'Secrets' {
586594
LogGroup 'Get secret and test whitespace handling' {
587595
$secretToRemove = Get-GitHubSecret @scope -Name $pipelineTestSecretName
588596
Write-Host "$($secretToRemove | Format-List | Out-String)"
589-
Write-Host "Testing that environment secrets with valid Environment property work correctly"
597+
Write-Host 'Testing that environment secrets with valid Environment property work correctly'
590598
}
591599
LogGroup 'Remove via pipeline' {
592600
{ $secretToRemove | Remove-GitHubSecret } | Should -Not -Throw

0 commit comments

Comments
 (0)