Skip to content

Commit

Permalink
Refactor GitHub.Tests to use parameter splatting for Connect-GitHubAc…
Browse files Browse the repository at this point in the history
…count and improve context count assertions
  • Loading branch information
MariusStorhaug committed Dec 12, 2024
1 parent 5157db1 commit 3800936
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/GitHub.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,26 @@ Describe 'GitHub' {
}

It 'Can be called with a GitHub App' {
{ Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY } | Should -Not -Throw
{ Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY } | Should -Not -Throw
Write-Verbose (Get-GitHubContext | Out-String) -Verbose
}

It 'Can list all contexts' {
Write-Verbose (Get-GitHubContext -ListAvailable | Out-String) -Verbose
$params = @{
ClientID = $env:TEST_APP_CLIENT_ID
PrivateKey = $env:TEST_APP_PRIVATE_KEY
}
{ Connect-GitHubAccount @params } | Should -Not -Throw
(Get-GitHubContext -ListAvailable).Count | Should -Be 3
}
It 'Can be called with a GitHub App and autoload installations' {
$params = @{
ClientID = $env:TEST_APP_CLIENT_ID
PrivateKey = $env:TEST_APP_PRIVATE_KEY
}
{ Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw
(Get-GitHubContext -ListAvailable).Count | Should -Be 7
}

It 'Can disconnect a specific context' {
{ Disconnect-GitHubAccount -Context 'github.com/github-actions/Organization/PSModule' -Silent } | Should -Not -Throw
(Get-GitHubContext -ListAvailable).Count | Should -Be 6
Connect-GitHubAccount
Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY
Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY -AutoloadInstallations
(Get-GitHubContext -ListAvailable).Count | Should -Be 7
}

Expand Down

0 comments on commit 3800936

Please sign in to comment.