From 5829c6291cbfd8b136806284b8f7ccd5518e5156 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 21:19:06 +0000 Subject: [PATCH 1/2] Add AfterAll block to clean up stub functions Agent-Logs-Url: https://github.com/Trenly/winget-pkgs/sessions/98d1cf1a-1495-4141-9546-a7d4ec864292 Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com> --- .../YamlCreate.InstallerDetection.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 b/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 index c3c45a8c97621..3dbb8ff9869c3 100644 --- a/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 +++ b/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 @@ -27,6 +27,13 @@ BeforeAll { } } +AfterAll { + # Clean up stub functions created in BeforeAll to prevent them from persisting in the session + Remove-Item Function:\Get-MSITable -ErrorAction SilentlyContinue + Remove-Item Function:\Get-MSIProperty -ErrorAction SilentlyContinue + Remove-Item Function:\Get-Win32ModuleResource -ErrorAction SilentlyContinue +} + Describe 'YamlCreate.InstallerDetection Module' { Context 'Module Import' { It 'Should import the module successfully' { From eb3936edca2917eb5cbe9dec2f52fe9abaa645f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 21:26:45 +0000 Subject: [PATCH 2/2] Track which stub functions were created in BeforeAll and only remove those in AfterAll Agent-Logs-Url: https://github.com/Trenly/winget-pkgs/sessions/d5eba23a-35fe-45d0-bef7-537b77b51ba8 Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com> --- .../YamlCreate.InstallerDetection.Tests.ps1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 b/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 index 3dbb8ff9869c3..eb95354aefb96 100644 --- a/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 +++ b/Tools/Modules/YamlCreate/YamlCreate.InstallerDetection/YamlCreate.InstallerDetection.Tests.ps1 @@ -5,33 +5,39 @@ 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 created in BeforeAll to prevent them from persisting in the session - Remove-Item Function:\Get-MSITable -ErrorAction SilentlyContinue - Remove-Item Function:\Get-MSIProperty -ErrorAction SilentlyContinue - Remove-Item Function:\Get-Win32ModuleResource -ErrorAction SilentlyContinue + # 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' {