Skip to content

Commit 03ac63c

Browse files
committed
Fix tests
1 parent fa1194e commit 03ac63c

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

GitHubReferences.ps1

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ function Get-GitHubReference
5757
Get-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch master
5858
5959
.EXAMPLE
60-
Get-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch master -MatchPrefix
60+
Get-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch powershell -MatchPrefix
61+
62+
Get the branch 'powershell' and if it doesn't exist, get all branches beginning with 'powershell'
6163
6264
.EXAMPLE
63-
Get-GitHubReference -OwnerName microsoft -RepositoryName -All
65+
Get-GitHubReference -Uri https://github.com/You/YourRepo -All
66+
67+
Get all references in the repository specified by URI
6468
#>
6569
[CmdletBinding(
6670
SupportsShouldProcess,
@@ -128,7 +132,7 @@ function Get-GitHubReference
128132
$reference = Resolve-Reference $Tag $Branch
129133

130134
if ($MatchPrefix) {
131-
$uriFragment = $uriFragment + "/matching-refs/$reference"
135+
$uriFragment = $uriFragment + "/matching-refs/$reference"
132136
$description = "Getting references matching $reference for $RepositoryName"
133137
}
134138
else
@@ -148,7 +152,6 @@ function Get-GitHubReference
148152
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
149153
}
150154

151-
Write-Host $uriFragment
152155
return Invoke-GHRestMethodMultipleResult @params
153156
}
154157

@@ -202,7 +205,7 @@ function New-GitHubReference
202205
New-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag powershellTagV1 -Sha aa218f56b14c9653891f9e74264a383fa43fefbd
203206
204207
.EXAMPLE
205-
New-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch master -Sha aa218f56b14c9653891f9e74264a383fa43fefbd
208+
New-GitHubReference -Uri https://github.com/You/YourRepo -Branch master -Sha aa218f56b14c9653891f9e74264a383fa43fefbd
206209
#>
207210
[CmdletBinding(SupportsShouldProcess)]
208211
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]
@@ -316,7 +319,11 @@ function Update-GitHubReference
316319
If not supplied here, the DefaultNoStatus configuration property value will be used.
317320
318321
.EXAMPLE
319-
Update-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Reference heads/master -Sha aa218f56b14c9653891f9e74264a383fa43fefbd
322+
Update-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch myBranch -Sha aa218f56b14c9653891f9e74264a383fa43fefbd
323+
324+
.EXAMPLE
325+
Update-GithubReference -Uri https://github.com/You/YourRepo -Tag myTag -Sha aa218f56b14c9653891f9e74264a383fa43fefbd
326+
320327
#>
321328
[CmdletBinding(
322329
SupportsShouldProcess,
@@ -431,10 +438,12 @@ function Remove-GitHubReference
431438
Remove-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag powershellTagV1
432439
433440
.EXAMPLE
434-
Remove-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch master
441+
Remove-GitHubReference -Uri https://github.com/You/YourRepo -Branch master
435442
436443
.EXAMPLE
437-
Remove-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Branch milestone1 -Confirm:$false
444+
Remove-GitHubReference -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag milestone1 -Confirm:$false
445+
446+
Remove the tag milestone1 without prompting for confirmation
438447
#>
439448
[CmdletBinding(SupportsShouldProcess, ConfirmImpact="High")]
440449
[Alias('Delete-GitHubReference')]

PowerShellForGitHub.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
'Get-GitHubRateLimit',
7878
'Get-GitHubReferrerTraffic',
7979
'Get-GitHubRelease',
80+
'Get-GitHubReference',
8081
'Get-GitHubRepository',
8182
'Get-GitHubRepositoryBranch',
8283
'Get-GitHubRepositoryCollaborator',

Tests/GitHubReferences.Tests.ps1

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ try
6969
}
7070
}
7171

72-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
72+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
7373
}
7474

7575
Describe 'Create a new tag in a repository' {
@@ -104,7 +104,7 @@ try
104104
}
105105
}
106106

107-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
107+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
108108
}
109109

110110
Describe 'Getting branch(es) from repository' {
@@ -174,7 +174,7 @@ try
174174
}
175175
}
176176

177-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
177+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
178178
}
179179

180180
Describe 'Getting tag(s) from repository' {
@@ -221,8 +221,8 @@ try
221221
Context 'On getting tags by prefix from a repository' {
222222
$tag1 = "elements_" + $([Guid]::NewGuid().ToString())
223223
$tag2 = "elements_" + $([Guid]::NewGuid().ToString())
224-
New-GitHubReference -OwnerName $ownerName -RepositoryName $repositoryName -Branch $tag1 -Sha $sha
225-
New-GitHubReference -OwnerName $ownerName -RepositoryName $repositoryName -Branch $tag2 -Sha $sha
224+
New-GitHubReference -OwnerName $ownerName -RepositoryName $repositoryName -Tag $tag1 -Sha $sha
225+
New-GitHubReference -OwnerName $ownerName -RepositoryName $repositoryName -Tag $tag2 -Sha $sha
226226

227227
$references = Get-GitHubReference -OwnerName $ownerName -RepositoryName $repositoryName -Tag "elements" -MatchPrefix
228228

@@ -241,12 +241,12 @@ try
241241
$references = Get-GitHubReference -Uri $repo.svn_url -Tag "uri" -MatchPrefix
242242

243243
It 'Should return all tags matching the prefix' {
244-
$expected = @("refs/tags/$branch1", "refs/tags/$branch2")
244+
$expected = @("refs/tags/$tag1", "refs/tags/$tag2")
245245
$references.ref | Should Be $expected
246246
}
247247
}
248248

249-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
249+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
250250
}
251251
Describe 'Getting all references from repository' {
252252
$repositoryName = [Guid]::NewGuid()
@@ -276,7 +276,7 @@ try
276276
}
277277
}
278278

279-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
279+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
280280
}
281281

282282
Describe 'Delete a branch from a repository' {
@@ -333,7 +333,7 @@ try
333333
}
334334
}
335335

336-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
336+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
337337
}
338338

339339
Describe 'Delete a Tag from a Repository' {
@@ -389,7 +389,7 @@ try
389389
}
390390
}
391391

392-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
392+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
393393
}
394394

395395
Describe 'Update a branch in a repository' {
@@ -420,7 +420,7 @@ try
420420
}
421421
}
422422

423-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
423+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
424424
}
425425

426426
Describe 'Update a tag in a repository' {
@@ -451,7 +451,7 @@ try
451451
}
452452
}
453453

454-
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
454+
$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName -Confirm:$false
455455
}
456456
}
457457
}

0 commit comments

Comments
 (0)