Files
fn_registry/registry/migrations/008_unit_tests.sql
egutierrez 256e038cbe feat: tablas unit_tests y e2e_tests
Migración 008 en registry.db para unit_tests con FTS5 (tests individuales extraídos de archivos de test). Migración 004 en operations.db para e2e_tests con FTS5 (tests de integración entre funciones dentro de apps).
2026-04-05 18:19:05 +02:00

38 lines
1.5 KiB
SQL

-- unit_tests: individual test cases extracted from test files
CREATE TABLE unit_tests (
id TEXT PRIMARY KEY,
function_id TEXT NOT NULL REFERENCES functions(id) ON DELETE CASCADE,
name TEXT NOT NULL,
code TEXT NOT NULL DEFAULT '',
file_path TEXT NOT NULL DEFAULT '',
lang TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
CREATE INDEX idx_unit_tests_function ON unit_tests(function_id);
CREATE INDEX idx_unit_tests_lang ON unit_tests(lang);
CREATE VIRTUAL TABLE unit_tests_fts USING fts5(
id, name, code, function_id, lang,
content='unit_tests',
content_rowid='rowid'
);
CREATE TRIGGER unit_tests_ai AFTER INSERT ON unit_tests BEGIN
INSERT INTO unit_tests_fts(rowid, id, name, code, function_id, lang)
VALUES (new.rowid, new.id, new.name, new.code, new.function_id, new.lang);
END;
CREATE TRIGGER unit_tests_ad AFTER DELETE ON unit_tests BEGIN
INSERT INTO unit_tests_fts(unit_tests_fts, rowid, id, name, code, function_id, lang)
VALUES ('delete', old.rowid, old.id, old.name, old.code, old.function_id, old.lang);
END;
CREATE TRIGGER unit_tests_au AFTER UPDATE ON unit_tests BEGIN
INSERT INTO unit_tests_fts(unit_tests_fts, rowid, id, name, code, function_id, lang)
VALUES ('delete', old.rowid, old.id, old.name, old.code, old.function_id, old.lang);
INSERT INTO unit_tests_fts(rowid, id, name, code, function_id, lang)
VALUES (new.rowid, new.id, new.name, new.code, new.function_id, new.lang);
END;