35 lines
1.3 KiB
PowerShell
35 lines
1.3 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$repositoryRoot = Split-Path -Parent $PSScriptRoot
|
|
$composeFile = Join-Path $repositoryRoot "deploy/docker-compose.test.yml"
|
|
$composeProject = "proxy-pool-postgres-test"
|
|
$previousPostgresURL = [Environment]::GetEnvironmentVariable("PROXY_POOL_TEST_POSTGRES_URL", "Process")
|
|
|
|
try {
|
|
docker compose -p $composeProject -f $composeFile up -d --wait --wait-timeout 60 postgres
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "starting PostgreSQL test fixture failed with exit code $LASTEXITCODE"
|
|
}
|
|
|
|
$env:PROXY_POOL_TEST_POSTGRES_URL = "postgres://proxy_pool_test:proxy-pool-test@127.0.0.1:15432/proxy_pool_test?sslmode=disable"
|
|
Push-Location $repositoryRoot
|
|
try {
|
|
go test -count=1 -tags=integration -timeout 60s ./internal/adapters/postgresadmin/...
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "PostgreSQL integration tests failed with exit code $LASTEXITCODE"
|
|
}
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
}
|
|
finally {
|
|
if ($null -eq $previousPostgresURL) {
|
|
Remove-Item Env:PROXY_POOL_TEST_POSTGRES_URL -ErrorAction SilentlyContinue
|
|
}
|
|
else {
|
|
$env:PROXY_POOL_TEST_POSTGRES_URL = $previousPostgresURL
|
|
}
|
|
docker compose -p $composeProject -f $composeFile down --volumes --remove-orphans
|
|
}
|