fix(tests): lower ValidateRange minimums and use .ps1 fake vmrun for Pester
This commit is contained in:
+14
-10
@@ -9,18 +9,22 @@ BeforeAll {
|
||||
$script:CloneBaseDir = Join-Path $env:TEMP "CI-Tests-CloneBase-$PID"
|
||||
New-Item -ItemType Directory -Path $script:CloneBaseDir -Force | Out-Null
|
||||
|
||||
# Fake vmrun.cmd — exits with %FAKE_VMRUN_EXIT% (default 0)
|
||||
# Fake vmrun.ps1 — exits with $env:FAKE_VMRUN_EXIT (default 0)
|
||||
# On success it also creates the destination VMX so the post-clone Test-Path passes.
|
||||
$script:FakeVmrun = Join-Path $env:TEMP "fake-vmrun-$PID.cmd"
|
||||
# Using .ps1 instead of .cmd avoids Windows cmd redirect limitations inside if blocks.
|
||||
$script:FakeVmrun = Join-Path $env:TEMP "fake-vmrun-$PID.ps1"
|
||||
Set-Content $script:FakeVmrun -Value @'
|
||||
@echo off
|
||||
if "%FAKE_VMRUN_EXIT%"=="" ( set _exit=0 ) else ( set _exit=%FAKE_VMRUN_EXIT% )
|
||||
if "%_exit%"=="0" (
|
||||
REM Create the destination VMX file so the caller's Test-Path check passes.
|
||||
REM The destination path is the 4th positional arg (after -T ws clone <template>).
|
||||
echo. > %5
|
||||
)
|
||||
exit /b %_exit%
|
||||
# Args: -T ws clone <template> <dst_vmx> linked -snapshot <snapshot>
|
||||
$exitCode = if ($env:FAKE_VMRUN_EXIT) { [int]$env:FAKE_VMRUN_EXIT } else { 0 }
|
||||
if ($exitCode -eq 0) {
|
||||
# Create the destination VMX (5th positional arg) so Test-Path in caller passes.
|
||||
# Real vmrun creates the clone dir+file; we must do the same here.
|
||||
$dstVmx = $args[4] # -T ws clone <tmpl> <dst> ...
|
||||
$dstDir = Split-Path $dstVmx -Parent
|
||||
if (-not (Test-Path $dstDir)) { New-Item -ItemType Directory -Path $dstDir -Force | Out-Null }
|
||||
Set-Content $dstVmx ''
|
||||
}
|
||||
exit $exitCode
|
||||
'@
|
||||
|
||||
# Fake template VMX — just needs to exist
|
||||
|
||||
Reference in New Issue
Block a user