Skip to content

Commit 3286cc3

Browse files
committed
Use $env: instead of [Environment]::Set...
1 parent 0c81af4 commit 3286cc3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_prepare_windows_host_for_app_distribution.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ if ($output -match [regex]::Escape($expectedNoFileSkipMessage)) {
145145
Write-Output "`n--- Test 5: If AMI version env == 0.2, only installs certificates"
146146
Remove-TestFiles
147147

148-
[Environment]::SetEnvironmentVariable('AMI_VERSION', '0.2', 'Machine')
148+
# Notice that setting via $env is session bound, which is perfect for unit tests.
149+
$env:AMI_VERSION = '0.2'
149150

150151
$output = & "$PSScriptRoot\..\bin\prepare_windows_host_for_app_distribution.ps1"
151152
$exitCode = $LASTEXITCODE
@@ -172,7 +173,8 @@ if ($output -match [regex]::Escape($expectedOnlyCertsMessage)) {
172173
Write-Output "`n--- Test 6: If AMI version env > 0.2, only installs certificates"
173174
Remove-TestFiles
174175

175-
[Environment]::SetEnvironmentVariable('AMI_VERSION', '1.0', 'Machine')
176+
# Notice that setting via $env is session bound, which is perfect for unit tests.
177+
$env:AMI_VERSION = '1.0'
176178

177179
$output = & "$PSScriptRoot\..\bin\prepare_windows_host_for_app_distribution.ps1"
178180
$exitCode = $LASTEXITCODE

0 commit comments

Comments
 (0)