From 2241f2dacbf0f00917e5e18795fe03143d093ece Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Thu, 27 Aug 2026 15:22:55 +0800 Subject: [PATCH] test: restore env vars after tests Signed-off-by: Chawye Hsu --- test/install.Tests.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/install.Tests.ps1 b/test/install.Tests.ps1 index 1c93d39..f6d0316 100644 --- a/test/install.Tests.ps1 +++ b/test/install.Tests.ps1 @@ -1,4 +1,7 @@ BeforeAll { + $script:OriginalScoop = $env:SCOOP + $script:OriginalScoopGlobal = $env:SCOOP_GLOBAL + $env:SCOOP = Join-Path $TestDrive 'scoop' $env:SCOOP_GLOBAL = Join-Path $TestDrive 'scoop-global' @@ -7,6 +10,20 @@ BeforeAll { . ".\$sut" } +AfterAll { + if ($null -eq $script:OriginalScoop) { + Remove-Item Env:SCOOP -ErrorAction SilentlyContinue + } else { + $env:SCOOP = $script:OriginalScoop + } + + if ($null -eq $script:OriginalScoopGlobal) { + Remove-Item Env:SCOOP_GLOBAL -ErrorAction SilentlyContinue + } else { + $env:SCOOP_GLOBAL = $script:OriginalScoopGlobal + } +} + Describe 'Get-Downloader' -Tag 'Proxy' { Context 'No proxy given via script parameter' { It 'Returns WebClient without proxy' {