Run backend tests with pytest after Dev deploy.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6ea36f7d1f
commit
9d79e3e92f
33 files changed
+188
-150
No files matched your search
+14
-24
@@ -80,39 +80,29 @@ function Test-PostgresSuite {
|
||||
return ($backend -in @("postgres", "postgresql", "pg")) -and $name.EndsWith("_test")
|
||||
}
|
||||
|
||||
Write-Host "Kansho local MVP tests"
|
||||
Write-Host "Kansho local tests (pytest wrapper)"
|
||||
Write-Host "Python: $py"
|
||||
Write-Host "Isolation: $($iso.Base)"
|
||||
Write-Host "No live provider/detect calls. Production DB/media untouched."
|
||||
Write-Host "Fail-closed stays testable; suites that need a fake provider set it themselves."
|
||||
Write-Host "Canonical backend suite: Gitea pytest on kansho_test after Dev deploy."
|
||||
$runBackend = Test-PostgresSuite
|
||||
if ($runBackend) {
|
||||
Write-Host "Backend tests: Postgres $($env:DB_NAME)"
|
||||
Write-Host "Backend pytest: Postgres $($env:DB_NAME)"
|
||||
} else {
|
||||
Write-Host "Backend Postgres-Suite: SKIP (KANSHO_DB_BACKEND=postgres und DB_NAME=kansho_test auf der Dev-Postgres; kanonisch Gitea auf dem Pi). Reine Unit-Tests ohne DB laufen trotzdem."
|
||||
Write-Host "Backend pytest: unit only (set KANSHO_DB_BACKEND=postgres and DB_NAME=kansho_test for integration)."
|
||||
}
|
||||
|
||||
try {
|
||||
$backendTests = Get-ChildItem -Path (Join-Path $root "backend\tests") -Filter "test_*.py" | Sort-Object Name
|
||||
if (-not $backendTests) {
|
||||
throw "no backend/tests/test_*.py files found"
|
||||
}
|
||||
|
||||
foreach ($test in $backendTests) {
|
||||
$needsPg = $false
|
||||
Invoke-Step -Name "backend pytest" -Action {
|
||||
Push-Location (Join-Path $root "backend")
|
||||
try {
|
||||
$needsPg = [bool](Select-String -Path $test.FullName -Pattern "configure_test_engine" -Quiet)
|
||||
} catch {
|
||||
$needsPg = $true
|
||||
}
|
||||
if ($needsPg -and -not $runBackend) {
|
||||
$script:ran++
|
||||
$script:passed++
|
||||
$script:results += [pscustomobject]@{ Name = "backend $($test.Name)"; Status = "SKIP" }
|
||||
continue
|
||||
}
|
||||
Invoke-Step -Name "backend $($test.Name)" -Action {
|
||||
& $py $test.FullName
|
||||
if ($runBackend) {
|
||||
& $py -m pytest tests -m "not slow" -ra --tb=short
|
||||
} else {
|
||||
& $py -m pytest tests -m "unit and not slow" -ra --tb=short
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,5 +151,5 @@ Write-Host ("{0} von {1} Schritten erfolgreich." -f $passed, $ran)
|
||||
if ($failed) {
|
||||
exit 1
|
||||
}
|
||||
Write-Host "MVP local acceptance: OK"
|
||||
Write-Host "local tests: OK"
|
||||
exit 0
|
||||
Reference in new issue
Block a user