param() $ErrorActionPreference = "Stop" Set-StrictMode -Version Latest $repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path $script = Join-Path $repo "scripts\verify-file-cache-mapping.ps1" $tempDir = Join-Path $repo ("runs\file-cache-mapping-test-" + [guid]::NewGuid().ToString("N")) $archiveList = Join-Path $tempDir "archive-list.txt" function Assert-True([bool]$Condition, [string]$Message) { if (-not $Condition) { throw $Message } } try { New-Item -ItemType Directory -Force -Path $tempDir | Out-Null @( "C:\redacted\importal\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\redacted-report.docx", "C:\redacted\importal\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\redacted-sheet.xlsx", "C:\redacted\other\ignored.txt" ) | Set-Content -LiteralPath $archiveList -Encoding UTF8 $output = & powershell -NoProfile -ExecutionPolicy Bypass -File $script -ArchiveListPath $archiveList -SkipDb if ($LASTEXITCODE -ne 0) { throw "verify-file-cache-mapping.ps1 failed with exit code $LASTEXITCODE" } $json = $output | ConvertFrom-Json Assert-True ($json.ok -eq $true) "ok should be true" Assert-True ($json.cache_checked -eq $true) "cache should be checked" Assert-True ($json.cache_candidate_count -eq 2) "cache candidate count should be 2" Assert-True ($json.cache_extension_counts.".docx" -eq 1) "docx extension count should be 1" Assert-True ($json.cache_extension_counts.".xlsx" -eq 1) "xlsx extension count should be 1" Assert-True ($json.hash_dir_length_counts."32" -eq 2) "hash dir length count should be 2" Assert-True ($json.raw_paths_printed -eq $false) "raw paths must not be printed" Assert-True ($json.file_contents_read -eq $false) "file contents must not be read" Assert-True ($json.file_paths_returned -eq $false) "file paths must not be returned" } finally { if (Test-Path -LiteralPath $tempDir) { Remove-Item -LiteralPath $tempDir -Recurse -Force } }