From a73d838f677f5f4a6f76284a02f1a6245b0fca34 Mon Sep 17 00:00:00 2001 From: Jimmy Briggs Date: Sat, 18 Nov 2023 12:19:23 -0500 Subject: [PATCH] feat: add GitConfig.Tests.ps1 --- Tests/GitConfig.Tests.ps1 | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Tests/GitConfig.Tests.ps1 diff --git a/Tests/GitConfig.Tests.ps1 b/Tests/GitConfig.Tests.ps1 new file mode 100644 index 0000000..515ab71 --- /dev/null +++ b/Tests/GitConfig.Tests.ps1 @@ -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' + } +}