@@ -131,6 +131,48 @@ Describe 'Coverage for remaining command and filesystem branches' {
131131 }
132132 }
133133
134+ It ' New-InitiateGitRepo stops with a default failure message when git init returns no details' {
135+ $repoPath = Join-Path $TestDrive ' git-init-nonzero'
136+ New-Item - ItemType Directory - Path $repoPath - Force | Out-Null
137+
138+ InModuleScope $script :moduleName - Parameters @ {RepoPath = $repoPath } {
139+ param ($RepoPath )
140+
141+ Mock Get-Command {[pscustomobject ]@ {Name = ' git' }} - ParameterFilter {$Name -eq ' git' }
142+ Mock Invoke-NovaGitCommand {
143+ [pscustomobject ]@ {
144+ ExitCode = 1
145+ Output = @ ()
146+ }
147+ }
148+
149+ $thrown = $null
150+ try {
151+ New-InitiateGitRepo - DirectoryPath $RepoPath - Confirm:$false
152+ }
153+ catch {
154+ $thrown = $_
155+ }
156+
157+ $thrown | Should -Not - BeNullOrEmpty
158+ $thrown.Exception.Message | Should - Be ' Failed to initialize Git repo.'
159+ $thrown.FullyQualifiedErrorId | Should - Be ' Nova.Dependency.GitRepositoryInitializationFailed'
160+ $thrown.CategoryInfo.Category | Should - Be ([System.Management.Automation.ErrorCategory ]::OpenError)
161+ $thrown.TargetObject | Should - Be $RepoPath
162+ }
163+ }
164+
165+ It ' Get-NovaGitInitializationFailureMessage includes git output details when they are available' {
166+ InModuleScope $script :moduleName {
167+ $result = [pscustomobject ]@ {
168+ ExitCode = 1
169+ Output = @ (' permission denied' )
170+ }
171+
172+ Get-NovaGitInitializationFailureMessage - Result $result | Should - Be ' Failed to initialize Git repo: permission denied'
173+ }
174+ }
175+
134176 It ' Get-NovaTestWorkflowContext prepares the Pester workflow state and resolves the report writers' - ForEach @ (
135177 @ {Build = $false ; ExpectedOperation = ' Run Pester tests and write test results' }
136178 @ {Build = $true ; ExpectedOperation = ' Build project, run Pester tests, and write test results' }
0 commit comments