Skip to content

Commit c601697

Browse files
Add repository/enterprise owner type guard to TEMPLATE and instructions docs
TEMPLATE.ps1 and both code snippets in tests.instructions.md were missing the if-guard for OwnerType values 'repository' and 'enterprise' that all actual test files already use. Without it the template's switch falls through silently, returning without making it explicit, and the instructions guide readers toward a pattern that omits the guard.
1 parent f1c850f commit c601697

2 files changed

Lines changed: 43 additions & 27 deletions

File tree

.github/instructions/tests.instructions.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,26 @@ whether the global `BeforeAll.ps1` already provisioned the repository.
9898
Primary repositories use `-AddReadme`, `-License 'mit'`, and `-Gitignore 'VisualStudio'` so that
9999
a default branch with content is available for tests that need commits (e.g., releases, tags).
100100

101+
Some auth cases (e.g., `repository`, `enterprise`) do not operate on a user- or org-owned repository.
102+
Skip provisioning for those owner types and set `$repo = $null` so that repo-dependent tests can
103+
be skipped cleanly:
104+
101105
```powershell
102106
$repoPrefix = "Test-$os-$TokenType"
103107
$repoName = "$repoPrefix-$id"
104-
$repoParams = @{
105-
Name = $repoName
106-
AddReadme = $true
107-
License = 'mit'
108-
Gitignore = 'VisualStudio'
109-
}
110-
$repo = switch ($OwnerType) {
111-
'user' { Set-GitHubRepository @repoParams }
112-
'organization' { Set-GitHubRepository @repoParams -Organization $Owner }
108+
if ($OwnerType -in ('repository', 'enterprise')) {
109+
$repo = $null
110+
} else {
111+
$repoParams = @{
112+
Name = $repoName
113+
AddReadme = $true
114+
License = 'mit'
115+
Gitignore = 'VisualStudio'
116+
}
117+
$repo = switch ($OwnerType) {
118+
'user' { Set-GitHubRepository @repoParams }
119+
'organization' { Set-GitHubRepository @repoParams -Organization $Owner }
120+
}
113121
}
114122
```
115123

@@ -142,15 +150,19 @@ Describe 'TestName' {
142150
143151
$repoPrefix = "Test-$os-$TokenType"
144152
$repoName = "$repoPrefix-$id"
145-
$repoParams = @{
146-
Name = $repoName
147-
AddReadme = $true
148-
License = 'mit'
149-
Gitignore = 'VisualStudio'
150-
}
151-
$repo = switch ($OwnerType) {
152-
'user' { Set-GitHubRepository @repoParams }
153-
'organization' { Set-GitHubRepository @repoParams -Organization $Owner }
153+
if ($OwnerType -in ('repository', 'enterprise')) {
154+
$repo = $null
155+
} else {
156+
$repoParams = @{
157+
Name = $repoName
158+
AddReadme = $true
159+
License = 'mit'
160+
Gitignore = 'VisualStudio'
161+
}
162+
$repo = switch ($OwnerType) {
163+
'user' { Set-GitHubRepository @repoParams }
164+
'organization' { Set-GitHubRepository @repoParams -Organization $Owner }
165+
}
154166
}
155167
}
156168

tests/TEMPLATE.ps1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,19 @@ Describe 'Template' {
4444
# Ensure the shared test repository exists. Set-GitHubRepository is idempotent.
4545
$repoPrefix = "Test-$os-$TokenType"
4646
$repoName = "$repoPrefix-$id"
47-
$repoParams = @{
48-
Name = $repoName
49-
AddReadme = $true
50-
License = 'mit'
51-
Gitignore = 'VisualStudio'
52-
}
53-
$repo = switch ($OwnerType) {
54-
'user' { Set-GitHubRepository @repoParams }
55-
'organization' { Set-GitHubRepository @repoParams -Organization $Owner }
47+
if ($OwnerType -in ('repository', 'enterprise')) {
48+
$repo = $null
49+
} else {
50+
$repoParams = @{
51+
Name = $repoName
52+
AddReadme = $true
53+
License = 'mit'
54+
Gitignore = 'VisualStudio'
55+
}
56+
$repo = switch ($OwnerType) {
57+
'user' { Set-GitHubRepository @repoParams }
58+
'organization' { Set-GitHubRepository @repoParams -Organization $Owner }
59+
}
5660
}
5761
}
5862
AfterAll {

0 commit comments

Comments
 (0)