Skip to content

Commit ea28d45

Browse files
committed
Fix tests
1 parent d7f456e commit ea28d45

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

PowerShellForGitHub.psd1

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# Functions to export from this module
4444
FunctionsToExport = @(
45-
'Add-GitHubLabel',
45+
'Add-GitHubIssueLabel',
4646
'Backup-GitHubConfiguration',
4747
'Clear-GitHubAuthentication',
4848
'ConvertFrom-Markdown',
@@ -89,13 +89,15 @@
8989
'New-GitHubRepositoryFork',
9090
'Remove-GithubAssignee',
9191
'Remove-GitHubComment',
92+
'Remove-GitHubIssueLabel',
9293
'Remove-GitHubLabel',
9394
'Remove-GitHubRepository',
9495
'Reset-GitHubConfiguration',
9596
'Restore-GitHubConfiguration',
9697
'Set-GitHubAuthentication',
9798
'Set-GitHubComment',
9899
'Set-GitHubConfiguration',
100+
'Set-GitHubIssueLabel',
99101
'Set-GitHubLabel',
100102
'Set-GitHubRepositoryTopic',
101103
'Split-GitHubUri',

Tests/GitHubLabels.tests.ps1

+43-11
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ if ($script:accessTokenConfigured)
283283
Context 'Adding labels to an issue' {
284284
$labelsToAdd = @('pri:lowest', 'pri:low', 'pri:medium', 'pri:high', 'pri:highest', 'bug', 'duplicate',
285285
'enhancement', 'up for grabs', 'question', 'discussion', 'wontfix', 'in progress', 'ready')
286-
$addedLabels = @(Add-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number -LabelName $labelsToAdd)
286+
$addedLabels = @(Add-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number -LabelName $labelsToAdd)
287287

288288
It 'Should return the expected number of labels' {
289289
$addedLabels.Count | Should be $script:defaultLabels.Count
@@ -295,37 +295,69 @@ if ($script:accessTokenConfigured)
295295
$labelIssues.Count | Should be $script:defaultLabels.Count
296296
}
297297
}
298+
299+
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
298300
}
299301
Describe 'Removing labels on an issue'{
302+
$repositoryName = [Guid]::NewGuid().Guid
303+
$null = New-GitHubRepository -RepositoryName $repositoryName
300304

301-
Remove-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Name "discussion" -Issue $issue.number
302-
Remove-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Name "question" -Issue $issue.number
303-
Remove-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Name "bug" -Issue $issue.number
304-
$labelIssues = Get-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number
305+
$issueName = [Guid]::NewGuid().Guid
306+
$issue = New-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repositoryName -Title $issueName
305307

306-
It 'Should have added the expected number of labels' {
307-
$labelIssues.Count | Should be ($script:defaultLabels.Count - 3)
308+
$labelsToAdd = @('pri:lowest', 'pri:low', 'pri:medium', 'pri:high', 'pri:highest', 'bug', 'duplicate',
309+
'enhancement', 'up for grabs', 'question', 'discussion', 'wontfix', 'in progress', 'ready')
310+
Add-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number -LabelName $labelsToAdd
311+
312+
Context 'For removing individual issues'{
313+
Remove-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Name "discussion" -Issue $issue.number
314+
Remove-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Name "question" -Issue $issue.number
315+
Remove-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Name "bug" -Issue $issue.number
316+
$labelIssues = Get-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number
317+
318+
It 'Should have added the expected number of labels' {
319+
$labelIssues.Count | Should be ($script:defaultLabels.Count - 3)
320+
}
308321
}
322+
323+
Context 'For removing all issues'{
324+
Remove-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number
325+
$labelIssues = Get-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number
326+
327+
It 'Should have added the expected number of labels' {
328+
$labelIssues.Count | Should be 0
329+
}
330+
}
331+
332+
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
309333
}
310334

311335
Describe 'Replacing labels on an issue'{
336+
$repositoryName = [Guid]::NewGuid().Guid
337+
$null = New-GitHubRepository -RepositoryName $repositoryName
338+
339+
$issueName = [Guid]::NewGuid().Guid
340+
$issue = New-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repositoryName -Title $issueName
341+
312342
$labelsToAdd = @('pri:lowest', 'pri:low', 'pri:medium', 'pri:high', 'pri:highest', 'bug', 'duplicate',
313343
'enhancement', 'up for grabs', 'question', 'discussion', 'wontfix', 'in progress', 'ready')
314344

315-
$addedLabels = @(Add-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number -LabelName $labelsToAdd -Replace)
345+
Add-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number -LabelName 'pri:medium'
346+
347+
$addedLabels = @(Set-GitHubIssueLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number -LabelName $labelsToAdd)
316348

317349
It 'Should return the expected number of labels' {
318-
$addedLabels.Count | Should be $script:defaultLabels.Count
350+
$addedLabels.Count | Should be $labelsToAdd.Count
319351
}
320352

321353
$labelIssues = Get-GitHubLabel -OwnerName $script:ownerName -RepositoryName $repositoryName -Issue $issue.number
322354

323355
It 'Should have added the expected number of labels' {
324356
$labelIssues.Count | Should be $script:defaultLabels.Count
325357
}
358+
359+
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
326360
}
327-
328-
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
329361
}
330362

331363
# Restore the user's configuration to its pre-test state

0 commit comments

Comments
 (0)