Skip to content

Commit

Permalink
feat: add GitConfig.Tests.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbrig committed Nov 18, 2023
1 parent a850be2 commit a73d838
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Tests/GitConfig.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Describe 'Testing Git Configuration Values' {
BeforeAll {
Function Get-GitConfigValue {
<#
.SYNOPSIS
Gets a value from the global git config file.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[String]$Key,
[Parameter()]
[String]$GitConfigPath = "$HOME\.gitconfig"
)

$Cmd = "& git config --global --get $Key"
Invoke-Expression -Command $Cmd
}

$Test_Email = Get-GitConfigValue -Key 'user.email'
$Test_DefaultMain = Get-GitConfigValue -Key 'init.defaultBranch'
$Test_SigningKey = Get-GitConfigValue -Key 'user.signingkey'
$Test_GPGProgram = Get-GitConfigValue -Key 'gpg.program'
$Test_CommitSigning = Get-GitConfigValue -Key 'commit.gpgSign'
$Test_TagSigning = Get-GitConfigValue -Key 'tag.forceSignAnnotated'
}

It 'Checks that user.email is set' {
$Test_Email | Should -Not -BeNullOrEmpty
}

It 'Checks that init.defaultBranch is set' {
$Test_DefaultMain | Should -Be 'main'
}

It 'Checks that user.signingkey is set' {
$Test_SigningKey | Should -Not -BeNullOrEmpty
}

It 'Checks that gpg.program is set' {
$Test_GPGProgram | Should -Not -BeNullOrEmpty
}

It 'Checks that commit.gpgSign is set' {
$Test_CommitSigning | Should -Be 'true'
}

It 'Checks that tag.forceSignAnnotated is set' {
$Test_TagSigning | Should -Be 'true'
}
}

0 comments on commit a73d838

Please sign in to comment.