Skip to content

Commit

Permalink
Try fixing it again
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed Nov 5, 2024
1 parent ae1d881 commit b5b3a29
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/GitDsc/GitDsc.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ BeforeAll {
Install-Module -Name PSDesiredStateConfiguration -Force -SkipPublisherCheck
}

# Because the module asserts that Git is installed before it will load, the function needs to be mocked
# This ensures that the tests can run even on a machine that does not have Git installed
Mock Assert-Git -ModuleName GitDsc { return $true }
Import-Module GitDsc

}

Describe 'List available DSC resources' {
Expand All @@ -32,9 +36,7 @@ InModuleScope -ModuleName GitDsc {
Describe 'GitClone' {

BeforeAll {
Mock Assert-Git { return $true }
Mock Invoke-GitClone -Verifiable

$global:HttpsUrl = 'https://github.com/microsoft/winget-dsc.git'
$global:TestGitRoot = Join-Path -Path $env:TEMP -ChildPath $(New-Guid)
}
Expand Down Expand Up @@ -89,10 +91,13 @@ InModuleScope -ModuleName GitDsc {
$gitCloneResource.Test() | Should -Be $true
Assert-MockCalled Invoke-GitRemote -Exactly 1
}

AfterAll {
# Clean up cloned folder
Remove-Item -Recurse -Force $global:TestGitRoot -ErrorAction 'SilentlyContinue'
}
}
}

AfterAll {
# Clean up cloned folder
Remove-Item -Recurse -Force $global:TestGitRoot -ErrorAction 'SilentlyContinue'
}

0 comments on commit b5b3a29

Please sign in to comment.