Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,41 @@ BeforeAll {

# Create stub functions for external dependencies that may not be available
# These are typically provided by external modules like MSI or Windows SDK tools
$Script:AddedGetMSITable = $false
if (-not (Get-Command Get-MSITable -ErrorAction SilentlyContinue)) {
function Global:Get-MSITable {
param([string]$Path)
return $null
}
$Script:AddedGetMSITable = $true
}

$Script:AddedGetMSIProperty = $false
if (-not (Get-Command Get-MSIProperty -ErrorAction SilentlyContinue)) {
function Global:Get-MSIProperty {
param([string]$Path, [string]$Property)
return $null
}
$Script:AddedGetMSIProperty = $true
}

$Script:AddedGetWin32ModuleResource = $false
if (-not (Get-Command Get-Win32ModuleResource -ErrorAction SilentlyContinue)) {
function Global:Get-Win32ModuleResource {
param([string]$Path, [switch]$DontLoadResource)
return @()
}
$Script:AddedGetWin32ModuleResource = $true
}
}

AfterAll {
# Clean up stub functions that were created in BeforeAll to prevent them from persisting in the session
if ($Script:AddedGetMSITable) { Remove-Item Function:\Get-MSITable -ErrorAction SilentlyContinue }
if ($Script:AddedGetMSIProperty) { Remove-Item Function:\Get-MSIProperty -ErrorAction SilentlyContinue }
if ($Script:AddedGetWin32ModuleResource) { Remove-Item Function:\Get-Win32ModuleResource -ErrorAction SilentlyContinue }
}

Describe 'YamlCreate.InstallerDetection Module' {
Context 'Module Import' {
It 'Should import the module successfully' {
Expand Down