Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Aug 17, 2024
1 parent 9d9386c commit 24039b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/public/Auth/Connect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@
)

$envVars = Get-ChildItem -Path 'Env:'
Write-Verbose 'Environment variables:'
Write-Verbose ($envVars | Format-Table -AutoSize | Out-String)
Write-Debug 'Environment variables:'
Write-Debug ($envVars | Format-Table -AutoSize | Out-String)
$gitHubToken = $envVars | Where-Object Name -In 'GH_TOKEN', 'GITHUB_TOKEN' | Select-Object -First 1
Write-Verbose "GitHub token: [$gitHubToken]"
Write-Debug "GitHub token: [$gitHubToken]"
$gitHubTokenPresent = $gitHubToken.count -gt 0
Write-Verbose "GitHub token present: [$gitHubTokenPresent]"
Write-DeBug "GitHub token present: [$gitHubTokenPresent]"
$AuthType = if ($gitHubTokenPresent) { 'sPAT' } else { $PSCmdlet.ParameterSetName }
Write-Verbose "AuthType: [$AuthType]"
switch ($AuthType) {
Expand Down
8 changes: 6 additions & 2 deletions src/public/Config/Get-GitHubConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ function Get-GitHubConfig {
'SecretVaultName',
'SecretVaultType',
'Scope',
'UserName'
'UserName',
'All'
)]
[string] $Name
[string] $Name = 'All'
)

$prefix = $script:Config.Prefix
Expand All @@ -46,6 +47,9 @@ function Get-GitHubConfig {
'^AccessToken$|^RefreshToken$' {
Get-StoreConfig -Name "$prefix$Name"
}
'^All$' {
Get-StoreConfig
}
default {
Get-StoreConfig -Name $Name
}
Expand Down
13 changes: 13 additions & 0 deletions tests/GitHub.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,17 @@ Describe 'GitHub' {
{ Invoke-GitHubAPI -ApiEndpoint '/rate_limit' -Method GET } | Should -Not -Throw
}
}
Context 'Get-GitHubConfig' {
It 'Get-GitHubConfig function exists' {
Get-Command Get-GitHubConfig | Should -Not -BeNullOrEmpty
}

It 'Can be called directly to get the ApiBaseUri' {
{ Get-GitHubConfig -Name ApiBaseUri } | Should -Not -Throw
}
It 'Can be called without a parameter' {
Write-Verbose (Get-GitHubConfig) -Verbose
{ Get-GitHubConfig } | Should -Not -Throw
}
}
}

0 comments on commit 24039b8

Please sign in to comment.