From b6aa35bf4acb5cfe290992f02a6a63ba3cfc5280 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Wed, 20 May 2020 21:23:08 -0400 Subject: [PATCH 01/13] Add tests to GitHubRepositories.tests.ps1 Add tests for GitHubRepositories.ps1 functions --- Tests/GitHubRepositories.tests.ps1 | 178 ++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 1 deletion(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index cd3c9fd3..36aaac64 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -14,7 +14,105 @@ $moduleRootPath = Split-Path -Path $PSScriptRoot -Parent try { - Describe 'Modifying repositories' { + # Define Script-scoped, readonly, hidden variables. + @{ + defaultRepoName = ([Guid]::NewGuid().Guid) + defaultRepoDesc = "This is a description." + defaultRepoHomePage = "https://www.microsoft.com/" + defaultRepoTopic = "microsoft" + modifiedRepoDesc = "This is a modified description." + }.GetEnumerator() | ForEach-Object { + Set-Variable -Force -Scope Script -Option ReadOnly -Visibility Private -Name $_.Key -Value $_.Value + } + + Describe 'Getting repositories' { + + Context -Name 'For getting a repository' -Fixture { + BeforeAll { + $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + } + AfterAll { + Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + } + + $newRepo = Get-GitHubRepository -RepositoryName $defaultRepoName + It 'Should get repository' { + $newRepo | Should Not BeNullOrEmpty + } + + It 'Name is correct' { + $newRepo.name | Should be $defaultRepoName + } + + It 'Description is correct' { + $newRepo.description | Should be $defaultRepoDesc + } + } + + Context -Name 'For getting a from default/repository' -Fixture { + BeforeAll { + $originalOwnerName = Get-GitHubConfiguration -Name DefaultOwnerName + $originalRepositoryName = Get-GitHubConfiguration -Name DefaultRepositoryName + } + AfterAll { + Set-GitHubConfiguration -DefaultOwnerName $originalOwnerName + Set-GitHubConfiguration -DefaultRepositoryName $originalRepositoryName + } + + $repo = Get-GitHubRepository + It 'Should get repository' { + $repo | Should Not BeNullOrEmpty + } + + It 'Owner is correct' { + $repo.owner.login | Should be Get-GitHubConfiguration -Name DefaultOwnerName + } + + It 'Name is correct' { + $repo.name | Should be Get-GitHubConfiguration -Name DefaultRepositoryName + } + } + } + + Describe 'Creating repositories' { + + Context -Name 'For creating a repository' -Fixture { + BeforeAll { + $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + } + AfterAll { + Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + } + + It 'Should get repository' { + $repo | Should Not BeNullOrEmpty + } + + It 'Name is correct' { + $repo.name | Should be $defaultRepoName + } + + It 'Description is correct' { + $repo.Description | Should be $defaultRepoDesc + } + } + } + + Describe 'Deleting repositories' { + + Context -Name 'For deleting a repository' -Fixture { + BeforeAll { + $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + } + + $delete = Remove-GitHubRepository -RepositoryName $defaultRepoName -Verbose + It 'Should get no content' { + $repo | Should BeNullOrEmpty + } + } + } + + Describe 'Renaming repositories' { Context -Name 'For renaming a repository' -Fixture { BeforeEach -Scriptblock { @@ -39,6 +137,84 @@ try } } } + + Describe 'Updating repositories' { + + Context -Name 'For creating a repository' -Fixture { + BeforeAll { + $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + } + AfterAll { + Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + } + + It 'Should have the new updated description' { + $updatedRepo = Update-GitHubRepository -RepositoryName $defaultRepoName -Description $modifiedRepoDesc + $updatedRepo.description | Should be $modifiedRepoDesc + } + + It 'Should have the new updated homepage url' { + $updatedRepo = Update-GitHubRepository -RepositoryName $defaultRepoName -Homepage $defaultRepoHomePage + $repo.homepage | Should be $defaultRepoHomePage + } + } + } + + Describe 'Get/set repository topic' { + + Context -Name 'For creating and getting a repository topic' -Fixture { + BeforeAll { + $repo = New-GitHubRepository -RepositoryName $defaultRepoName -AutoInit + } + AfterAll { + Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + } + + It 'Should have the expected topic' { + $topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Name ($defaultRepoTopic) + $updatedRepo.names[0] | Should be $defaultRepoTopics + } + + It 'Should have no topics' { + $topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Clear + $updatedRepo.names | Should BeNullOrEmpty + } + } + } + + Describe 'Get repository languages' { + + Context -Name 'For getting repository languages' -Fixture { + BeforeAll { + $repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit + } + AfterAll { + Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + } + + $languages = Get-GitHubRepositoryLanguage -RepositoryName $defaultRepoName + It 'Should be empty' { + $languages | Should BeNullOrEmpty + } + } + } + + Describe 'Get repository tags' { + + Context -Name 'For getting repository tags' -Fixture { + BeforeAll { + $repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit + } + AfterAll { + Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + } + + $tags = Get-GitHubRepositoryTag -RepositoryName $defaultRepoName + It 'Should be empty' { + $tags | Should BeNullOrEmpty + } + } + } } finally { From f3652ee85ded8b5e58ab719e908f41fee0d52336 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Tue, 26 May 2020 18:20:46 -0400 Subject: [PATCH 02/13] Fix minor errors and remove verbose Remove -Verbose, parenthesis, and s from Topics --- Tests/GitHubRepositories.tests.ps1 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 36aaac64..8f527836 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -32,7 +32,7 @@ try $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)" } $newRepo = Get-GitHubRepository -RepositoryName $defaultRepoName @@ -81,7 +81,7 @@ try $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)" } It 'Should get repository' { @@ -105,7 +105,7 @@ try $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit } - $delete = Remove-GitHubRepository -RepositoryName $defaultRepoName -Verbose + $delete = Remove-GitHubRepository -RepositoryName $defaultRepoName It 'Should get no content' { $repo | Should BeNullOrEmpty } @@ -119,7 +119,6 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit $suffixToAddToRepo = "_renamed" $newRepoName = "$($repo.Name)$suffixToAddToRepo" - Write-Verbose "New repo name shall be: '$newRepoName'" } It "Should have the expected new repository name - by URI" { $renamedRepo = $repo | Rename-GitHubRepository -NewName $newRepoName -Confirm:$false @@ -133,7 +132,7 @@ try ## cleanup temp testing repository AfterEach -Scriptblock { ## variables from BeforeEach scriptblock are accessible here, but not variables from It scriptblocks, so need to make URI (instead of being able to use $renamedRepo variable from It scriptblock) - Remove-GitHubRepository -Uri "$($repo.svn_url)$suffixToAddToRepo" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)$suffixToAddToRepo" } } } @@ -145,7 +144,7 @@ try $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)" } It 'Should have the new updated description' { @@ -167,12 +166,12 @@ try $repo = New-GitHubRepository -RepositoryName $defaultRepoName -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)" } It 'Should have the expected topic' { - $topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Name ($defaultRepoTopic) - $updatedRepo.names[0] | Should be $defaultRepoTopics + $topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Name $defaultRepoTopic + $updatedRepo.names[0] | Should be $defaultRepoTopic } It 'Should have no topics' { @@ -189,7 +188,7 @@ try $repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)" } $languages = Get-GitHubRepositoryLanguage -RepositoryName $defaultRepoName @@ -206,7 +205,7 @@ try $repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose + Remove-GitHubRepository -Uri "$($repo.svn_url)" } $tags = Get-GitHubRepositoryTag -RepositoryName $defaultRepoName From 37c5825c71d530b92a7c03c7b052d2fb8751dc77 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Tue, 26 May 2020 20:27:31 -0400 Subject: [PATCH 03/13] Added -OwnerName, fixed other bugs, refactored some tests --- Tests/GitHubRepositories.tests.ps1 | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index f45b1593..5b379b82 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -16,11 +16,9 @@ try { # Define Script-scoped, readonly, hidden variables. @{ - defaultRepoName = ([Guid]::NewGuid().Guid) defaultRepoDesc = "This is a description." defaultRepoHomePage = "https://www.microsoft.com/" defaultRepoTopic = "microsoft" - modifiedRepoDesc = "This is a modified description." }.GetEnumerator() | ForEach-Object { Set-Variable -Force -Scope Script -Option ReadOnly -Visibility Private -Name $_.Key -Value $_.Value } @@ -79,7 +77,7 @@ try $repos = Get-GitHubRepository -OrganizationName $script:organizationName -Type All It "Should have results for the organization" { - $repo.name | Should BeIn $repos.name + $repo.Name | Should BeIn $repos.Name } AfterAll -ScriptBlock { @@ -139,7 +137,7 @@ try } It "Should have the expected new repository name - by Elements" { - $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -NewName $newRepoName -Confirm:$false + $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -NewName $newRepoName -Confirm:$false $renamedRepo.Name | Should be $newRepoName } ## cleanup temp testing repository @@ -154,7 +152,8 @@ try Context -Name 'For creating a repository' -Fixture { BeforeAll { - $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + $repoName = ([Guid]::NewGuid().Guid) + "_name" + $repo = New-GitHubRepository -RepositoryName $repoName -Description $defaultRepoDesc -AutoInit } AfterAll { Remove-GitHubRepository -Uri "$($repo.svn_url)" @@ -165,7 +164,7 @@ try } It 'Name is correct' { - $repo.name | Should be $defaultRepoName + $repo.Name | Should be $repoName } It 'Description is correct' { @@ -178,10 +177,10 @@ try Context -Name 'For deleting a repository' -Fixture { BeforeAll { - $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } - $delete = Remove-GitHubRepository -RepositoryName $defaultRepoName + $delete = Remove-GitHubRepository -RepositoryName $repo.Name It 'Should get no content' { $repo | Should BeNullOrEmpty } @@ -246,7 +245,7 @@ try } It "Should have the expected new repository name - by Elements" { - $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -NewName $newRepoName -Confirm:$false + $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -NewName $newRepoName -Confirm:$false $renamedRepo.Name | Should be $newRepoName } ## cleanup temp testing repository @@ -261,19 +260,20 @@ try Context -Name 'For creating a repository' -Fixture { BeforeAll { - $repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit + $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } AfterAll { Remove-GitHubRepository -Uri "$($repo.svn_url)" } It 'Should have the new updated description' { - $updatedRepo = Update-GitHubRepository -RepositoryName $defaultRepoName -Description $modifiedRepoDesc + $modifiedRepoDesc = $defaultRepoDesc + "_modified" + $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -Description $modifiedRepoDesc $updatedRepo.description | Should be $modifiedRepoDesc } It 'Should have the new updated homepage url' { - $updatedRepo = Update-GitHubRepository -RepositoryName $defaultRepoName -Homepage $defaultRepoHomePage + $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -Homepage $defaultRepoHomePage $repo.homepage | Should be $defaultRepoHomePage } } @@ -283,19 +283,19 @@ try Context -Name 'For creating and getting a repository topic' -Fixture { BeforeAll { - $repo = New-GitHubRepository -RepositoryName $defaultRepoName -AutoInit + $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { Remove-GitHubRepository -Uri "$($repo.svn_url)" } It 'Should have the expected topic' { - $topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Name $defaultRepoTopic + $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.Name -Name $defaultRepoTopic $updatedRepo.names[0] | Should be $defaultRepoTopic } It 'Should have no topics' { - $topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Clear + $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.Name -Clear $updatedRepo.names | Should BeNullOrEmpty } } @@ -305,13 +305,13 @@ try Context -Name 'For getting repository languages' -Fixture { BeforeAll { - $repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit + $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { Remove-GitHubRepository -Uri "$($repo.svn_url)" } - $languages = Get-GitHubRepositoryLanguage -RepositoryName $defaultRepoName + $languages = Get-GitHubRepositoryLanguage -OwnerName $repo.owner.login -RepositoryName $repo.Name It 'Should be empty' { $languages | Should BeNullOrEmpty } @@ -322,13 +322,13 @@ try Context -Name 'For getting repository tags' -Fixture { BeforeAll { - $repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit + $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { Remove-GitHubRepository -Uri "$($repo.svn_url)" } - $tags = Get-GitHubRepositoryTag -RepositoryName $defaultRepoName + $tags = Get-GitHubRepositoryTag -OwnerName $repo.owner.login -RepositoryName $repo.Name It 'Should be empty' { $tags | Should BeNullOrEmpty } From a2631dd5747ae34dbdac2bcdd09b90dc26eb768a Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Thu, 28 May 2020 21:47:38 -0400 Subject: [PATCH 04/13] Various fixes --- Tests/GitHubRepositories.tests.ps1 | 123 +++++++---------------------- 1 file changed, 27 insertions(+), 96 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 5b379b82..b6ef62f7 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -38,13 +38,13 @@ try $privateRepos = Get-GitHubRepository -Visibility Private It "Should have the public repo" { - $publicRepo.Name | Should BeIn $publicRepos.Name - $publicRepo.Name | Should Not BeIn $privateRepos.Name + $publicRepo.name | Should BeIn $publicRepos.name + $publicRepo.name | Should Not BeIn $privateRepos.name } It "Should have the private repo" { - $privateRepo.Name | Should BeIn $privateRepos.Name - $privateRepo.Name | Should Not BeIn $publicRepos.Name + $privateRepo.name | Should BeIn $privateRepos.name + $privateRepo.name | Should Not BeIn $publicRepos.name } It 'Should not permit bad combination of parameters' { @@ -77,7 +77,7 @@ try $repos = Get-GitHubRepository -OrganizationName $script:organizationName -Type All It "Should have results for the organization" { - $repo.Name | Should BeIn $repos.Name + $repo.name | Should BeIn $repos.name } AfterAll -ScriptBlock { @@ -103,17 +103,17 @@ try $returned | Should -BeOfType PSCustomObject } - $returned = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name + $returned = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name It "Should be a single result using Elements ParameterSet" { $returned | Should -BeOfType PSCustomObject } It 'Should not permit additional parameters' { - { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -Type All } | Should Throw + { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Type All } | Should Throw } It 'Should require both OwnerName and RepositoryName' { - { Get-GitHubRepository -RepositoryName $repo.Name } | Should Throw + { Get-GitHubRepository -RepositoryName $repo.name } | Should Throw { Get-GitHubRepository -Uri "https://github.com/$script:ownerName" } | Should Throw } @@ -123,40 +123,15 @@ try } } - Describe 'Modifying repositories' { - Context -Name 'For renaming a repository' -Fixture { - BeforeEach -Scriptblock { - $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit - $suffixToAddToRepo = "_renamed" - $newRepoName = "$($repo.Name)$suffixToAddToRepo" - Write-Verbose "New repo name shall be: '$newRepoName'" - } - It "Should have the expected new repository name - by URI" { - $renamedRepo = $repo | Rename-GitHubRepository -NewName $newRepoName -Confirm:$false - $renamedRepo.Name | Should be $newRepoName - } - - It "Should have the expected new repository name - by Elements" { - $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -NewName $newRepoName -Confirm:$false - $renamedRepo.Name | Should be $newRepoName - } - ## cleanup temp testing repository - AfterEach -Scriptblock { - ## variables from BeforeEach scriptblock are accessible here, but not variables from It scriptblocks, so need to make URI (instead of being able to use $renamedRepo variable from It scriptblock) - Remove-GitHubRepository -Uri "$($repo.svn_url)$suffixToAddToRepo" - } - } - } - Describe 'Creating repositories' { Context -Name 'For creating a repository' -Fixture { BeforeAll { - $repoName = ([Guid]::NewGuid().Guid) + "_name" + $repoName = ([Guid]::NewGuid().Guid) $repo = New-GitHubRepository -RepositoryName $repoName -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" + Remove-GitHubRepository -Uri $repo.svn_url } It 'Should get repository' { @@ -164,11 +139,11 @@ try } It 'Name is correct' { - $repo.Name | Should be $repoName + $repo.name | Should be $repoName } It 'Description is correct' { - $repo.Description | Should be $defaultRepoDesc + $repo.description | Should be $defaultRepoDesc } } } @@ -180,7 +155,7 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } - $delete = Remove-GitHubRepository -RepositoryName $repo.Name + $delete = Remove-GitHubRepository -RepositoryName $repo.name It 'Should get no content' { $repo | Should BeNullOrEmpty } @@ -189,64 +164,20 @@ try Describe 'Renaming repositories' { - AfterAll -ScriptBlock { - Remove-GitHubRepository -Uri $repo.svn_url - } - } - - Context 'For public repos' { - # Skipping these tests for now, as it would run for a _very_ long time. - # No obviously good way to verify this. - } - - Context 'For a specific repo' { - BeforeAll -Scriptblock { - $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit - - # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments - $repo = $repo - } - - $returned = Get-GitHubRepository -Uri $repo.svn_url - It "Should be a single result using Uri ParameterSet" { - $returned | Should -BeOfType PSCustomObject - } - - $returned = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name - It "Should be a single result using Elements ParameterSet" { - $returned | Should -BeOfType PSCustomObject - } - - It 'Should not permit additional parameters' { - { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -Type All } | Should Throw - } - - It 'Should require both OwnerName and RepositoryName' { - { Get-GitHubRepository -RepositoryName $repo.Name } | Should Throw - { Get-GitHubRepository -Uri "https://github.com/$script:ownerName" } | Should Throw - } - - AfterAll -ScriptBlock { - Remove-GitHubRepository -Uri $repo.svn_url - } - } - } - - Describe 'Modifying repositories' { Context -Name 'For renaming a repository' -Fixture { BeforeEach -Scriptblock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit $suffixToAddToRepo = "_renamed" - $newRepoName = "$($repo.Name)$suffixToAddToRepo" + $newRepoName = "$($repo.name)$suffixToAddToRepo" } It "Should have the expected new repository name - by URI" { $renamedRepo = $repo | Rename-GitHubRepository -NewName $newRepoName -Confirm:$false - $renamedRepo.Name | Should be $newRepoName + $renamedRepo.name | Should be $newRepoName } It "Should have the expected new repository name - by Elements" { - $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -NewName $newRepoName -Confirm:$false - $renamedRepo.Name | Should be $newRepoName + $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -NewName $newRepoName -Confirm:$false + $renamedRepo.name | Should be $newRepoName } ## cleanup temp testing repository AfterEach -Scriptblock { @@ -263,17 +194,17 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" + Remove-GitHubRepository -Uri $repo.svn_url } It 'Should have the new updated description' { $modifiedRepoDesc = $defaultRepoDesc + "_modified" - $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -Description $modifiedRepoDesc + $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Description $modifiedRepoDesc $updatedRepo.description | Should be $modifiedRepoDesc } It 'Should have the new updated homepage url' { - $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name -Homepage $defaultRepoHomePage + $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Homepage $defaultRepoHomePage $repo.homepage | Should be $defaultRepoHomePage } } @@ -286,16 +217,16 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" + Remove-GitHubRepository -Uri $repo.svn_url } It 'Should have the expected topic' { - $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.Name -Name $defaultRepoTopic + $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Name $defaultRepoTopic $updatedRepo.names[0] | Should be $defaultRepoTopic } It 'Should have no topics' { - $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.Name -Clear + $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Clear $updatedRepo.names | Should BeNullOrEmpty } } @@ -308,10 +239,10 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" + Remove-GitHubRepository -Uri $repo.svn_url } - $languages = Get-GitHubRepositoryLanguage -OwnerName $repo.owner.login -RepositoryName $repo.Name + $languages = Get-GitHubRepositoryLanguage -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should be empty' { $languages | Should BeNullOrEmpty } @@ -325,10 +256,10 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { - Remove-GitHubRepository -Uri "$($repo.svn_url)" + Remove-GitHubRepository -Uri $repo.svn_url } - $tags = Get-GitHubRepositoryTag -OwnerName $repo.owner.login -RepositoryName $repo.Name + $tags = Get-GitHubRepositoryTag -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should be empty' { $tags | Should BeNullOrEmpty } From 67eb3e853b6bbc3f7a483e68edae7ac6c68c3e4d Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Thu, 28 May 2020 21:56:19 -0400 Subject: [PATCH 05/13] Other fixes --- Tests/GitHubRepositories.tests.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index b6ef62f7..4981c03a 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -156,6 +156,7 @@ try } $delete = Remove-GitHubRepository -RepositoryName $repo.name + $repo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should get no content' { $repo | Should BeNullOrEmpty } @@ -222,12 +223,14 @@ try It 'Should have the expected topic' { $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Name $defaultRepoTopic - $updatedRepo.names[0] | Should be $defaultRepoTopic + $updatedRepo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name + $updatedRepo.name | Should be $defaultRepoTopic } It 'Should have no topics' { $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Clear - $updatedRepo.names | Should BeNullOrEmpty + $updatedRepo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name + $updatedRepo.name | Should BeNullOrEmpty } } } From 0c6a7fd8764bea553b677f5bb6f894b8530bbc92 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Fri, 29 May 2020 09:34:41 -0400 Subject: [PATCH 06/13] Added another test for Get-GitHubRepositoryLanguage --- Tests/GitHubRepositories.tests.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 4981c03a..2c8d4bc6 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -249,6 +249,11 @@ try It 'Should be empty' { $languages | Should BeNullOrEmpty } + + $languages = Get-GitHubRepositoryLanguage -OwnerName "microsoft" -RepositoryName "PowerShellForGitHub" + It 'Should be empty' { + "PowerShell" | Should BeIn $languages + } } } From 93b67937ecf4857d36f0af5f167912cad1b0c53a Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Mon, 1 Jun 2020 15:51:29 -0400 Subject: [PATCH 07/13] Added -Confirm:$false to Remove-GitHubRepository Added remaining -Confirm:$false following new merges that added -Confirm:$false functionality. --- Tests/GitHubRepositories.tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 53a68039..02527e1f 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -131,7 +131,7 @@ try $repo = New-GitHubRepository -RepositoryName $repoName -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url + Remove-GitHubRepository -Uri $repo.svn_url-Confirm:$false } It 'Should get repository' { @@ -155,7 +155,7 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } - $delete = Remove-GitHubRepository -RepositoryName $repo.name + $delete = Remove-GitHubRepository -RepositoryName $repo.name -Confirm:$false $repo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should get no content' { $repo | Should BeNullOrEmpty @@ -195,7 +195,7 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } It 'Should have the new updated description' { @@ -218,7 +218,7 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } It 'Should have the expected topic' { @@ -242,7 +242,7 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } $languages = Get-GitHubRepositoryLanguage -OwnerName $repo.owner.login -RepositoryName $repo.name @@ -264,7 +264,7 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } $tags = Get-GitHubRepositoryTag -OwnerName $repo.owner.login -RepositoryName $repo.name From 2dea437137ac62c8bb28e878837f49f3e0f28b8a Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Mon, 1 Jun 2020 16:24:25 -0400 Subject: [PATCH 08/13] Remove unnecessary comment --- Tests/GitHubRepositories.tests.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 02527e1f..63324092 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -4,8 +4,6 @@ <# .Synopsis Tests for GitHubRepositories.ps1 module -.Description - Many cmdlets are indirectly tested in the course of other tests (New-GitHubRepository, Remove-GitHubRepository), and may not have explicit tests here #> # This is common test code setup logic for all Pester test files From da793df5143c785682a6d6c3ec1f62bf3d2d06a5 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Mon, 1 Jun 2020 22:39:27 -0400 Subject: [PATCH 09/13] Several fixes to tests and code cleanup --- Tests/GitHubRepositories.tests.ps1 | 136 +++++++++++++++-------------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 63324092..a7f4148d 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -32,22 +32,23 @@ try $privateRepo = $privateRepo } - $publicRepos = @(Get-GitHubRepository -Visibility Public) - $privateRepos = @(Get-GitHubRepository -Visibility Private) - It "Should have the public repo" { - $publicRepo.name | Should BeIn $publicRepos.name - $publicRepo.name | Should Not BeIn $privateRepos.name + $publicRepos = @(Get-GitHubRepository -Visibility Public) + $privateRepos = @(Get-GitHubRepository -Visibility Private) + $publicRepo.name | Should -BeIn $publicRepos.name + $publicRepo.name | Should -Not -BeIn $privateRepos.name } It "Should have the private repo" { - $privateRepo.name | Should BeIn $privateRepos.name - $privateRepo.name | Should Not BeIn $publicRepos.name + $publicRepos = @(Get-GitHubRepository -Visibility Public) + $privateRepos = @(Get-GitHubRepository -Visibility Private) + $privateRepo.name | Should -BeIn $privateRepos.name + $privateRepo.name | Should -Not -BeIn $publicRepos.name } It 'Should not permit bad combination of parameters' { - { Get-GitHubRepository -Type All -Visibility All } | Should Throw - { Get-GitHubRepository -Type All -Affiliation Owner } | Should Throw + { Get-GitHubRepository -Type All -Visibility All } | Should -Throw + { Get-GitHubRepository -Type All -Affiliation Owner } | Should -Throw } AfterAll -ScriptBlock { @@ -57,11 +58,10 @@ try } Context 'For any user' { - $repos = @(Get-GitHubRepository -OwnerName 'octocat' -Type Public) - It "Should have results for The Octocat" { + $repos = @(Get-GitHubRepository -OwnerName 'octocat' -Type Public) $repos.Count | Should -BeGreaterThan 0 - $repos[0].owner.login | Should Be 'octocat' + $repos[0].owner.login | Should -Be 'octocat' } } @@ -73,9 +73,9 @@ try $repo = $repo } - $repos = @(Get-GitHubRepository -OrganizationName $script:organizationName -Type All) It "Should have results for the organization" { - $repo.name | Should BeIn $repos.name + $repos = @(Get-GitHubRepository -OrganizationName $script:organizationName -Type All) + $repo.name | Should -BeIn $repos.name } AfterAll -ScriptBlock { @@ -89,30 +89,30 @@ try } Context 'For a specific repo' { - BeforeAll -Scriptblock { + BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments $repo = $repo } - $result = Get-GitHubRepository -Uri $repo.svn_url It "Should be a single result using Uri ParameterSet" { + $result = Get-GitHubRepository -Uri $repo.svn_url $result | Should -BeOfType PSCustomObject } - $result = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.Name It "Should be a single result using Elements ParameterSet" { + $result = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name $result | Should -BeOfType PSCustomObject } It 'Should not permit additional parameters' { - { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Type All } | Should Throw + { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Type All } | Should -Throw } It 'Should require both OwnerName and RepositoryName' { - { Get-GitHubRepository -RepositoryName $repo.name } | Should Throw - { Get-GitHubRepository -Uri "https://github.com/$script:ownerName" } | Should Throw + { Get-GitHubRepository -RepositoryName $repo.name } | Should -Throw + { Get-GitHubRepository -Uri "https://github.com/$script:ownerName" } | Should -Throw } AfterAll -ScriptBlock { @@ -124,24 +124,25 @@ try Describe 'Creating repositories' { Context -Name 'For creating a repository' -Fixture { - BeforeAll { + BeforeAll -ScriptBlock { $repoName = ([Guid]::NewGuid().Guid) $repo = New-GitHubRepository -RepositoryName $repoName -Description $defaultRepoDesc -AutoInit } - AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url-Confirm:$false - } It 'Should get repository' { - $repo | Should Not BeNullOrEmpty + $repo | Should -Not -BeNullOrEmpty } It 'Name is correct' { - $repo.name | Should be $repoName + $repo.name | Should -Be $repoName } It 'Description is correct' { - $repo.description | Should be $defaultRepoDesc + $repo.description | Should -Be $defaultRepoDesc + } + + AfterAll -ScriptBlock { + Remove-GitHubRepository -Uri $repo.svn_url-Confirm:$false } } } @@ -149,14 +150,13 @@ try Describe 'Deleting repositories' { Context -Name 'For deleting a repository' -Fixture { - BeforeAll { + BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } - $delete = Remove-GitHubRepository -RepositoryName $repo.name -Confirm:$false - $repo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should get no content' { - $repo | Should BeNullOrEmpty + $delete = Remove-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Confirm:$false + { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name } | Should -Throw } } } @@ -169,18 +169,18 @@ try $suffixToAddToRepo = "_renamed" $newRepoName = "$($repo.name)$suffixToAddToRepo" } + It "Should have the expected new repository name - by URI" { $renamedRepo = $repo | Rename-GitHubRepository -NewName $newRepoName -Confirm:$false - $renamedRepo.name | Should be $newRepoName + $renamedRepo.name | Should -Be $newRepoName } It "Should have the expected new repository name - by Elements" { $renamedRepo = Rename-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -NewName $newRepoName -Confirm:$false - $renamedRepo.name | Should be $newRepoName + $renamedRepo.name | Should -Be $newRepoName } - ## cleanup temp testing repository + AfterEach -Scriptblock { - ## variables from BeforeEach scriptblock are accessible here, but not variables from It scriptblocks, so need to make URI (instead of being able to use $renamedRepo variable from It scriptblock) Remove-GitHubRepository -Uri "$($repo.svn_url)$suffixToAddToRepo" -Confirm:$false } } @@ -189,22 +189,23 @@ try Describe 'Updating repositories' { Context -Name 'For creating a repository' -Fixture { - BeforeAll { + BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit } - AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false - } It 'Should have the new updated description' { $modifiedRepoDesc = $defaultRepoDesc + "_modified" $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Description $modifiedRepoDesc - $updatedRepo.description | Should be $modifiedRepoDesc + $updatedRepo.description | Should -Be $modifiedRepoDesc } It 'Should have the new updated homepage url' { $updatedRepo = Update-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Homepage $defaultRepoHomePage - $repo.homepage | Should be $defaultRepoHomePage + $updatedRepo.homepage | Should -Be $defaultRepoHomePage + } + + AfterAll -ScriptBlock { + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } } } @@ -212,23 +213,24 @@ try Describe 'Get/set repository topic' { Context -Name 'For creating and getting a repository topic' -Fixture { - BeforeAll { + BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } - AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false - } It 'Should have the expected topic' { - $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Name $defaultRepoTopic - $updatedRepo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name - $updatedRepo.name | Should be $defaultRepoTopic + Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Name $defaultRepoTopic + $topic = Get-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name + $topic.names | Should -Be $defaultRepoTopic } It 'Should have no topics' { - $topic = Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Clear - $updatedRepo = Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name - $updatedRepo.name | Should BeNullOrEmpty + Set-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name -Clear + $topic = Get-GitHubRepositoryTopic -OwnerName $repo.owner.login -RepositoryName $repo.name + $topic.names | Should -BeNullOrEmpty + } + + AfterAll -ScriptBlock { + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } } } @@ -236,21 +238,22 @@ try Describe 'Get repository languages' { Context -Name 'For getting repository languages' -Fixture { - BeforeAll { + BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } - AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false - } - $languages = Get-GitHubRepositoryLanguage -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should be empty' { - $languages | Should BeNullOrEmpty + $languages = Get-GitHubRepositoryLanguage -OwnerName $repo.owner.login -RepositoryName $repo.name + $languages | Should -BeNullOrEmpty } - $languages = Get-GitHubRepositoryLanguage -OwnerName "microsoft" -RepositoryName "PowerShellForGitHub" - It 'Should be empty' { - "PowerShell" | Should BeIn $languages + It 'Should be contain PowerShell' { + $languages = Get-GitHubRepositoryLanguage -OwnerName "microsoft" -RepositoryName "PowerShellForGitHub" + $languages.PowerShell | Should -Not -BeNullOrEmpty + } + + AfterAll -ScriptBlock { + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } } } @@ -258,16 +261,17 @@ try Describe 'Get repository tags' { Context -Name 'For getting repository tags' -Fixture { - BeforeAll { + BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit } - AfterAll { - Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false - } - $tags = Get-GitHubRepositoryTag -OwnerName $repo.owner.login -RepositoryName $repo.name It 'Should be empty' { - $tags | Should BeNullOrEmpty + $tags = Get-GitHubRepositoryTag -OwnerName $repo.owner.login -RepositoryName $repo.name + $tags | Should -BeNullOrEmpty + } + + AfterAll -ScriptBlock { + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } } } From 64d9c6a08fa87b30268cc236b14ea59b065eed5c Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Tue, 2 Jun 2020 15:11:09 -0400 Subject: [PATCH 10/13] Added name to contribution list --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1cf400fa..dff45883 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -485,6 +485,7 @@ Thank you to all of our contributors, no matter how big or small the contributio - **[Matt Boren (@mtboren)](http://github.com/mtboren)** - **[Shannon Deminick (@Shazwazza)](http://github.com/Shazwazza)** - **[Jess Pomfret (@jpomfret)](https://github.com/jpomfret)** +- **[Giuseppe Campanelli (@themilanfan)](https://github.com/themilanfan)** ---------- From 18f97b2a19cd8f8161d6c6e0ecf0ebcf6e7d13ac Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Wed, 3 Jun 2020 15:28:55 -0400 Subject: [PATCH 11/13] Update Tests/GitHubRepositories.tests.ps1 Co-authored-by: Howard Wolosky --- Tests/GitHubRepositories.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index a7f4148d..92a1145e 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -142,7 +142,7 @@ try } AfterAll -ScriptBlock { - Remove-GitHubRepository -Uri $repo.svn_url-Confirm:$false + Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false } } } From 33dd7b983e9a10089e77e80685ff16c56a469640 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Wed, 3 Jun 2020 15:29:04 -0400 Subject: [PATCH 12/13] Update Tests/GitHubRepositories.tests.ps1 Co-authored-by: Howard Wolosky --- Tests/GitHubRepositories.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 92a1145e..92c0ec5b 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -247,7 +247,7 @@ try $languages | Should -BeNullOrEmpty } - It 'Should be contain PowerShell' { + It 'Should contain PowerShell' { $languages = Get-GitHubRepositoryLanguage -OwnerName "microsoft" -RepositoryName "PowerShellForGitHub" $languages.PowerShell | Should -Not -BeNullOrEmpty } From 65c4a06a535701f34e1b79d9d35a65e0ee3869c2 Mon Sep 17 00:00:00 2001 From: Giuseppe Campanelli Date: Wed, 3 Jun 2020 17:48:56 -0400 Subject: [PATCH 13/13] Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments --- Tests/GitHubRepositories.tests.ps1 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1 index 92c0ec5b..76c2f9b7 100644 --- a/Tests/GitHubRepositories.tests.ps1 +++ b/Tests/GitHubRepositories.tests.ps1 @@ -127,6 +127,10 @@ try BeforeAll -ScriptBlock { $repoName = ([Guid]::NewGuid().Guid) $repo = New-GitHubRepository -RepositoryName $repoName -Description $defaultRepoDesc -AutoInit + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $repoName = $repoName + $repo = $repo } It 'Should get repository' { @@ -152,10 +156,13 @@ try Context -Name 'For deleting a repository' -Fixture { BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $repo = $repo } It 'Should get no content' { - $delete = Remove-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Confirm:$false + Remove-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name -Confirm:$false { Get-GitHubRepository -OwnerName $repo.owner.login -RepositoryName $repo.name } | Should -Throw } } @@ -168,6 +175,9 @@ try $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit $suffixToAddToRepo = "_renamed" $newRepoName = "$($repo.name)$suffixToAddToRepo" + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $newRepoName = $newRepoName } It "Should have the expected new repository name - by URI" { @@ -191,6 +201,9 @@ try Context -Name 'For creating a repository' -Fixture { BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -Description $defaultRepoDesc -AutoInit + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $repo = $repo } It 'Should have the new updated description' { @@ -215,6 +228,9 @@ try Context -Name 'For creating and getting a repository topic' -Fixture { BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $repo = $repo } It 'Should have the expected topic' { @@ -240,6 +256,9 @@ try Context -Name 'For getting repository languages' -Fixture { BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $repo = $repo } It 'Should be empty' { @@ -263,6 +282,9 @@ try Context -Name 'For getting repository tags' -Fixture { BeforeAll -ScriptBlock { $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit + + # Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments + $repo = $repo } It 'Should be empty' {