kin: auto-commit after pipeline

This commit is contained in:
Gros Frumos 2026-03-17 17:26:31 +02:00
parent 17d7806838
commit eab9e951ab
12 changed files with 1696 additions and 5 deletions

View file

@ -502,3 +502,42 @@ def test_migrate_pid_guard_is_idempotent():
assert before == after
assert "pid" in after
conn.close()
# ---------------------------------------------------------------------------
# Schema KIN-084: pipeline_log в SCHEMA-строке и _migrate()
# Конвенция #387: DDL-парсинг SCHEMA-строки
# ---------------------------------------------------------------------------
def test_schema_string_contains_pipeline_log_table():
"""Регрессия KIN-084: SCHEMA-строка содержит CREATE TABLE pipeline_log."""
from core.db import SCHEMA
assert "CREATE TABLE IF NOT EXISTS pipeline_log" in SCHEMA
def test_schema_pipeline_log_has_required_columns():
"""SCHEMA pipeline_log содержит все обязательные колонки."""
from core.db import SCHEMA
start = SCHEMA.index("CREATE TABLE IF NOT EXISTS pipeline_log")
end = SCHEMA.index(");", start) + 2
ddl = SCHEMA[start:end]
assert "pipeline_id INTEGER" in ddl
assert "ts " in ddl
assert "level " in ddl
assert "message " in ddl
assert "extra_json " in ddl
def test_migrate_creates_pipeline_log_on_fresh_init(conn):
"""Свежая инициализация: pipeline_log существует."""
tables = {r["name"] for r in conn.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()}
assert "pipeline_log" in tables
def test_migrate_creates_pipeline_log_if_missing():
"""_migrate создаёт pipeline_log если таблица отсутствует в старой БД."""
conn = _old_schema_conn()
_migrate(conn)
tables = {r["name"] for r in conn.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()}
assert "pipeline_log" in tables
conn.close()