AP0.1: Backend, Frontend minimal, Tests und CI fuer Dev/Prod-Deploy.
Deploy Development / deploy (push) Successful in 41s
Test Suite / compose-smoke (push) Failing after 3s
Test Suite / pytest-backend (push) Has been skipped
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 1m7s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Deploy Development / deploy (push) Successful in 41s
Test Suite / compose-smoke (push) Failing after 3s
Test Suite / pytest-backend (push) Has been skipped
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 1m7s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1ce20d8bdb
commit
0e5bf72dee
30 files changed
+828
-422
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def client(monkeypatch):
|
||||
monkeypatch.setenv("SKIP_DB_MIGRATE", "1")
|
||||
import importlib
|
||||
|
||||
import main as main_module
|
||||
|
||||
importlib.reload(main_module)
|
||||
return TestClient(main_module.app)
|
||||
|
||||
|
||||
def test_app_importable():
|
||||
import main
|
||||
|
||||
assert main.app is not None
|
||||
|
||||
|
||||
def test_health_endpoint(client):
|
||||
response = client.get("/api/health")
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["app"] == "jinkendo-kairo"
|
||||
assert payload["status"] in {"ok", "degraded"}
|
||||
assert payload["db"] in {"ok", "error"}
|
||||
@@ -0,0 +1,57 @@
|
||||
"""Migration runner tests (require PostgreSQL)."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import psycopg2
|
||||
import pytest
|
||||
|
||||
import run_migrations
|
||||
|
||||
|
||||
def _db_available() -> bool:
|
||||
try:
|
||||
conn = psycopg2.connect(
|
||||
host=os.getenv("DB_HOST", "localhost"),
|
||||
port=os.getenv("DB_PORT", "5432"),
|
||||
dbname=os.getenv("DB_NAME", "kairo_dev"),
|
||||
user=os.getenv("DB_USER", "kairo_dev"),
|
||||
password=os.getenv("DB_PASSWORD", "dev_password"),
|
||||
)
|
||||
conn.close()
|
||||
return True
|
||||
except psycopg2.OperationalError:
|
||||
return False
|
||||
|
||||
|
||||
pytestmark = pytest.mark.skipif(not _db_available(), reason="PostgreSQL nicht erreichbar")
|
||||
|
||||
|
||||
def test_migration_runner_finds_migrations():
|
||||
migrations_dir = run_migrations.migrations_directory()
|
||||
files = run_migrations.migration_files(migrations_dir)
|
||||
names = [name for name, _ in files]
|
||||
assert "001_init_core" in names
|
||||
|
||||
|
||||
def test_migration_runner_is_idempotent():
|
||||
assert run_migrations.main() == 0
|
||||
assert run_migrations.main() == 0
|
||||
|
||||
conn = run_migrations.connect_with_retry(max_retries=5)
|
||||
executed = run_migrations.executed_migrations(conn)
|
||||
conn.close()
|
||||
assert "001_init_core" in executed
|
||||
|
||||
|
||||
def test_core_table_exists():
|
||||
conn = run_migrations.connect_with_retry(max_retries=5)
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT COUNT(*) FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_name = 'kairo_app_meta'
|
||||
"""
|
||||
)
|
||||
assert cur.fetchone()[0] == 1
|
||||
conn.close()
|
||||
Reference in new issue
Block a user