нейрослоп удаляю и пишу все БД с нуля
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
# Прогон приёмочных тестов БД в отдельной базе pvz_test.
|
||||
# Запуск: powershell -ExecutionPolicy Bypass -File .\run_tests.ps1
|
||||
$ErrorActionPreference = 'Continue'
|
||||
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
||||
|
||||
$root = $PSScriptRoot
|
||||
$container = 'pvz-postgres'
|
||||
|
||||
$running = docker inspect -f '{{.State.Running}}' $container 2>$null
|
||||
if ($running -ne 'true') {
|
||||
Write-Host 'Контейнер pvz-postgres не запущен. Выполните: docker compose up -d' -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host '=== Создание чистой базы pvz_test ===' -ForegroundColor Cyan
|
||||
docker exec $container psql -U postgres -d postgres -v ON_ERROR_STOP=1 `
|
||||
-c "DROP DATABASE IF EXISTS pvz_test;" `
|
||||
-c "CREATE DATABASE pvz_test;"
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Write-Host '=== Загрузка pvz_database.sql ===' -ForegroundColor Cyan
|
||||
docker cp (Join-Path $root 'pvz_database.sql') "${container}:/tmp/pvz_database.sql" | Out-Null
|
||||
docker exec $container psql -U postgres -d pvz_test -v ON_ERROR_STOP=1 -f /tmp/pvz_database.sql
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
docker exec $container psql -U postgres -d postgres -c "DROP DATABASE IF EXISTS pvz_test;" | Out-Null
|
||||
Write-Host 'Ошибка загрузки pvz_database.sql' -ForegroundColor Red
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
Write-Host '=== Выполнение pvz_tests.sql ===' -ForegroundColor Cyan
|
||||
docker cp (Join-Path $root 'pvz_tests.sql') "${container}:/tmp/pvz_tests.sql" | Out-Null
|
||||
$output = cmd /c "docker exec $container psql -U postgres -d pvz_test -f /tmp/pvz_tests.sql 2>&1" | Out-String
|
||||
Write-Host $output
|
||||
|
||||
docker exec $container psql -U postgres -d postgres -c "DROP DATABASE IF EXISTS pvz_test;" | Out-Null
|
||||
|
||||
if ($output -match 'FAIL') {
|
||||
Write-Host '=== Обнаружены FAIL ===' -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host '=== Все проверки пройдены, FAIL не найдено ===' -ForegroundColor Green
|
||||
Reference in New Issue
Block a user