Skip to content

Commit a84ae98

Browse files
Extract testNames to shared TestRepos.ps1 data file; rethrow stale org cleanup failure
1 parent 0d7811e commit a84ae98

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

tests/AfterAll.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ LogGroup 'AfterAll - Global Test Teardown' {
2929
}
3030
Write-Host "Cleaning up test repositories for OSes: $($osNames -join ', ')"
3131

32-
$testNames = @('Environments', 'Secrets', 'Variables', 'Releases', 'Actions')
33-
$testNamesWithExtraRepos = @('Secrets', 'Variables')
32+
# Source the single authoritative list of test-file repositories so setup and teardown
33+
# always operate on the same set. See tests/Data/TestRepos.ps1.
34+
$testRepos = . "$PSScriptRoot/Data/TestRepos.ps1"
35+
$testNames = $testRepos.TestNames
36+
$testNamesWithExtraRepos = $testRepos.TestNamesWithExtraRepos
3437
foreach ($authCase in $authCases) {
3538
$authCase.GetEnumerator() | ForEach-Object { Set-Variable -Name $_.Key -Value $_.Value }
3639

tests/BeforeAll.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ LogGroup 'BeforeAll - Global Test Setup' {
2828
}
2929
Write-Host "Creating test repositories for OSes: $($osNames -join ', ')"
3030

31-
# Test files that require their own per-test-file repository.
32-
# Each test file's per-context BeforeAll also calls Set-GitHubRepository as a safety net,
33-
# so this list is an optimization rather than a hard dependency.
34-
$testNames = @('Environments', 'Secrets', 'Variables', 'Releases', 'Actions')
35-
36-
# Test files that need companion repositories (-2, -3) for org-scoped SelectedRepository tests.
37-
$testNamesWithExtraRepos = @('Secrets', 'Variables')
31+
# Source the single authoritative list of test-file repositories so setup and teardown
32+
# always operate on the same set. See tests/Data/TestRepos.ps1.
33+
$testRepos = . "$PSScriptRoot/Data/TestRepos.ps1"
34+
$testNames = $testRepos.TestNames
35+
$testNamesWithExtraRepos = $testRepos.TestNamesWithExtraRepos
3836

3937
foreach ($authCase in $authCases) {
4038
$authCase.GetEnumerator() | ForEach-Object { Set-Variable -Name $_.Key -Value $_.Value }

tests/Data/TestRepos.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Test files that require their own per-test-file repository.
2+
# Each test file's per-context BeforeAll also calls Set-GitHubRepository as a safety net,
3+
# so this list is an optimization rather than a hard dependency. BeforeAll.ps1 and
4+
# AfterAll.ps1 both source this file so setup and teardown always operate on the same set.
5+
@{
6+
# Test files that each need a primary repository.
7+
TestNames = @('Environments', 'Secrets', 'Variables', 'Releases', 'Actions')
8+
9+
# Subset that also need companion -2/-3 repositories for org-scoped SelectedRepository tests.
10+
TestNamesWithExtraRepos = @('Secrets', 'Variables')
11+
}

tests/Organizations.Tests.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ Describe 'Organizations' {
6868
Remove-GitHubOrganization -Name $orgName -Confirm:$false -Context $cleanupOrgContext
6969
Write-Host "Stale org [$orgName] removed."
7070
} catch {
71-
Write-Host "WARNING: Could not remove stale org [$orgName]: $($_.Exception.Message)"
71+
# Rethrow — if the org exists but we can't remove it, New-GitHubOrganization
72+
# will fail anyway. Failing here gives a clearer root-cause message.
73+
throw "Could not remove stale org [$orgName]: $($_.Exception.Message)"
7274
}
7375
} else {
7476
Write-Host "No stale org found for [$orgName]."

0 commit comments

Comments
 (0)