Skip to content

Commit 363aa96

Browse files
committed
Fix review comments
1 parent a301c9c commit 363aa96

File tree

1 file changed

+37
-84
lines changed

1 file changed

+37
-84
lines changed

Tests/GitHubRepositories.tests.ps1

Lines changed: 37 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ try
382382
}
383383

384384
It 'Should return objects of the correct type' {
385-
$publicRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
386-
$privateRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
385+
$publicRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
386+
$privateRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
387387
}
388388

389389
It "Should return the correct membership" {
@@ -403,9 +403,9 @@ try
403403
}
404404

405405
It 'Should return objects of the correct type' {
406-
$publicRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
407-
$publicRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
408-
$ownerRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
406+
$publicRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
407+
$publicRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
408+
$ownerRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
409409
}
410410

411411
It "Should return the correct membership" {
@@ -426,7 +426,7 @@ try
426426
}
427427

428428
It 'Should return objects of the correct type' {
429-
$ownerRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
429+
$ownerRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
430430
}
431431

432432
It "Should return the correct membership" {
@@ -448,8 +448,8 @@ try
448448
}
449449

450450
It 'Should return objects of the correct type' {
451-
$sortedRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
452-
$sortedDescendingRepos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
451+
$sortedRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
452+
$sortedDescendingRepos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
453453
}
454454

455455
It "Should return the correct membership order" {
@@ -525,7 +525,7 @@ try
525525
}
526526

527527
It 'Should return an object of the correct type' {
528-
$repos.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
528+
$repos[0].PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
529529
}
530530

531531
It 'Should return at least one result' {
@@ -956,7 +956,7 @@ try
956956
}
957957

958958
It 'Should return an object of the correct type' {
959-
$topic.PSObject.TypeNames[0] | Should -Be 'GitHub.Topic'
959+
$topic.PSObject.TypeNames[0] | Should -Be 'GitHub.RepositoryTopic'
960960
}
961961

962962
It 'Should return the correct properties' {
@@ -988,8 +988,8 @@ try
988988
$contributors.PSObject.TypeNames[0] | Should -Be 'GitHub.User'
989989
}
990990

991-
It 'Should return at least one result' {
992-
$contributors.count | Should -BeGreaterOrEqual 1
991+
It 'Should return expected number of contributors' {
992+
$contributors.Count | Should -Be 1
993993
}
994994

995995
It "Should return the correct membership" {
@@ -1008,11 +1008,12 @@ try
10081008
}
10091009

10101010
It 'Should return objects of the correct type' {
1011-
$contributors.PSObject.TypeNames[0] | Should -Be 'GitHub.User'
1011+
$contributors[0].PSObject.TypeNames[0] | Should -Be 'GitHub.RepositoryContributorStatistics'
1012+
$contributors[0].author.PSObject.TypeNames[0] = 'GitHub.User'
10121013
}
10131014

1014-
It 'Should return at least one result' {
1015-
$contributors.count | Should -BeGreaterOrEqual 1
1015+
It 'Should return expected number of contributors' {
1016+
$contributors.Count | Should -Be 1
10161017
}
10171018

10181019
It 'Should return the correct membership' {
@@ -1068,11 +1069,29 @@ try
10681069
}
10691070

10701071
It 'Should return objects of the correct type' {
1071-
$collaborators.PSObject.TypeNames[0] | Should -Be 'GitHub.User'
1072+
$collaborators[0].PSObject.TypeNames[0] | Should -Be 'GitHub.User'
10721073
}
10731074

1074-
It 'Should return at least one result' {
1075-
$collaborators.count | Should -BeGreaterOrEqual 1
1075+
It 'Should return expected number of collaborators' {
1076+
$collaborators.Count | Should -Be 1
1077+
}
1078+
1079+
It "Should return the correct membership" {
1080+
$repo.owner.login | Should -BeIn $collaborators.login
1081+
}
1082+
}
1083+
1084+
Context 'When getting GitHub Repository Collaborators (via pipeline)' {
1085+
BeforeAll {
1086+
$collaborators = @($repo | Get-GitHubRepositoryCollaborator)
1087+
}
1088+
1089+
It 'Should return objects of the correct type' {
1090+
$collaborators[0].PSObject.TypeNames[0] | Should -Be 'GitHub.User'
1091+
}
1092+
1093+
It 'Should return expected number of collaborators' {
1094+
$collaborators.Count | Should -Be 1
10761095
}
10771096

10781097
It "Should return the correct membership" {
@@ -1139,72 +1158,6 @@ try
11391158
}
11401159
}
11411160

1142-
Describe 'Contributors for a repository' {
1143-
BeforeAll {
1144-
$repo = New-GitHubRepository -RepositoryName ([guid]::NewGuid().Guid) -AutoInit
1145-
}
1146-
1147-
AfterAll {
1148-
$null = Remove-GitHubRepository -Uri $repo.RepositoryUrl -Confirm:$false
1149-
}
1150-
1151-
Context -Name 'Obtaining contributors for repository' -Fixture {
1152-
$contributors = @(Get-GitHubRepositoryContributor -Uri $repo.RepositoryUrl)
1153-
1154-
It 'Should return expected number of contributors' {
1155-
$contributors.Count | Should -Be 1
1156-
$contributors[0].PSObject.TypeNames[0] = 'GitHub.RepositoryContributor'
1157-
}
1158-
}
1159-
1160-
Context -Name 'Obtaining contributors for repository (via pipeline)' -Fixture {
1161-
$contributors = @($repo | Get-GitHubRepositoryContributor -IncludeStatistics)
1162-
1163-
It 'Should return expected number of contributors' {
1164-
$contributors.Count | Should -Be 1
1165-
$contributors[0].PSObject.TypeNames[0] = 'GitHub.RepositoryContributor'
1166-
}
1167-
}
1168-
1169-
Context -Name 'Obtaining contributor statistics for repository' -Fixture {
1170-
$stats = @(Get-GitHubRepositoryContributor -Uri $repo.RepositoryUrl -IncludeStatistics)
1171-
1172-
It 'Should return expected number of contributors' {
1173-
$stats.Count | Should -Be 1
1174-
$stats[0].PSObject.TypeNames[0] = 'GitHub.RepositoryContributorStatistics'
1175-
$stats[0].author.PSObject.TypeNames[0] = 'GitHub.User'
1176-
}
1177-
}
1178-
}
1179-
1180-
Describe 'Collaborators for a repository' {
1181-
BeforeAll {
1182-
$repo = New-GitHubRepository -RepositoryName ([guid]::NewGuid().Guid) -AutoInit
1183-
}
1184-
1185-
AfterAll {
1186-
$null = Remove-GitHubRepository -Uri $repo.RepositoryUrl -Confirm:$false
1187-
}
1188-
1189-
Context -Name 'Obtaining collaborators for repository' -Fixture {
1190-
$collaborators = @(Get-GitHubRepositoryCollaborator -Uri $repo.RepositoryUrl)
1191-
1192-
It 'Should return expected number of collaborators' {
1193-
$collaborators.Count | Should -Be 1
1194-
$collaborators[0].PSObject.TypeNames[0] = 'GitHub.RepositoryCollaborator'
1195-
}
1196-
}
1197-
1198-
Context -Name 'Obtaining collaborators for repository (via pipeline)' -Fixture {
1199-
$collaborators = @($repo | Get-GitHubRepositoryCollaborator)
1200-
1201-
It 'Should return expected number of collaborators' {
1202-
$collaborators.Count | Should -Be 1
1203-
$collaborators[0].PSObject.TypeNames[0] = 'GitHub.RepositoryCollaborator'
1204-
}
1205-
}
1206-
}
1207-
12081161
Describe 'GitHubRepositories\Test-GitHubRepositoryVulnerabilityAlert' {
12091162
BeforeAll -ScriptBlock {
12101163
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid)

0 commit comments

Comments
 (0)