Files

32 lines
1.7 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$projectRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../..'))
$configuration = @{}
Get-Content -LiteralPath (Join-Path $projectRoot '.runtime/local-cluster/services.env') | ForEach-Object {
$pair = $_ -split '=', 2
if ($pair.Count -eq 2 -and ($pair[0] -like 'TEST_*' -or $pair[0] -eq 'RUN_REDIS_TESTS')) {
$configuration[$pair[0]] = $pair[1]
}
}
# Tests intentionally clear their database. Only this dedicated local target is allowed.
if ($configuration['TEST_DATABASE_URL'] -ne 'jdbc:postgresql://127.0.0.1:15432/webup_integration' -or
$configuration['TEST_DATABASE_USER'] -ne 'webup_test' -or
$configuration['TEST_REDIS_HOST'] -ne '127.0.0.1' -or $configuration['TEST_REDIS_PORT'] -ne '16379' -or
$configuration['RUN_REDIS_TESTS'] -ne 'true') {
throw 'Only the dedicated disposable local PostgreSQL / Redis targets are accepted.'
}
$previous = @{}
foreach ($key in $configuration.Keys) { $previous[$key] = [Environment]::GetEnvironmentVariable($key, 'Process') }
$originalJava = $env:JAVA_HOME
Push-Location (Join-Path $projectRoot 'backend')
try {
foreach ($key in $configuration.Keys) { [Environment]::SetEnvironmentVariable($key, $configuration[$key], 'Process') }
$bundledJava = Join-Path $projectRoot '.tools/jdk-21.0.13.0.2+1'
if (Test-Path -LiteralPath $bundledJava) { $env:JAVA_HOME = $bundledJava }
& .\mvnw.cmd verify
if ($LASTEXITCODE -ne 0) { throw 'Real PostgreSQL / Redis verification failed.' }
} finally {
foreach ($key in $previous.Keys) { [Environment]::SetEnvironmentVariable($key, $previous[$key], 'Process') }
$env:JAVA_HOME = $originalJava
Pop-Location
}