From 256e038cbe0c238dfb65532844f8ae64206d0a6a Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Sun, 5 Apr 2026 18:19:05 +0200 Subject: [PATCH] feat: tablas unit_tests y e2e_tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- fn_operations/migrations/004_e2e_tests.sql | 42 ++++++++++++++++++++++ registry/migrations/008_unit_tests.sql | 37 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 fn_operations/migrations/004_e2e_tests.sql create mode 100644 registry/migrations/008_unit_tests.sql diff --git a/fn_operations/migrations/004_e2e_tests.sql b/fn_operations/migrations/004_e2e_tests.sql new file mode 100644 index 00000000..ae3398cd --- /dev/null +++ b/fn_operations/migrations/004_e2e_tests.sql @@ -0,0 +1,42 @@ +-- e2e_tests: integration tests that verify function composition within an app +CREATE TABLE e2e_tests ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + description TEXT NOT NULL DEFAULT '', + relation_id TEXT DEFAULT '' REFERENCES relations(id), + steps TEXT NOT NULL DEFAULT '[]', + input_fixture TEXT NOT NULL DEFAULT '{}', + expected TEXT NOT NULL DEFAULT '{}', + last_status TEXT NOT NULL DEFAULT '', + last_run_at TEXT NOT NULL DEFAULT '', + execution_id TEXT NOT NULL DEFAULT '', + duration_ms INTEGER NOT NULL DEFAULT 0, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL +); + +CREATE INDEX idx_e2e_tests_relation ON e2e_tests(relation_id); +CREATE INDEX idx_e2e_tests_status ON e2e_tests(last_status); + +CREATE VIRTUAL TABLE e2e_tests_fts USING fts5( + id, name, description, steps, + content='e2e_tests', + content_rowid='rowid' +); + +CREATE TRIGGER e2e_tests_ai AFTER INSERT ON e2e_tests BEGIN + INSERT INTO e2e_tests_fts(rowid, id, name, description, steps) + VALUES (new.rowid, new.id, new.name, new.description, new.steps); +END; + +CREATE TRIGGER e2e_tests_ad AFTER DELETE ON e2e_tests BEGIN + INSERT INTO e2e_tests_fts(e2e_tests_fts, rowid, id, name, description, steps) + VALUES ('delete', old.rowid, old.id, old.name, old.description, old.steps); +END; + +CREATE TRIGGER e2e_tests_au AFTER UPDATE ON e2e_tests BEGIN + INSERT INTO e2e_tests_fts(e2e_tests_fts, rowid, id, name, description, steps) + VALUES ('delete', old.rowid, old.id, old.name, old.description, old.steps); + INSERT INTO e2e_tests_fts(rowid, id, name, description, steps) + VALUES (new.rowid, new.id, new.name, new.description, new.steps); +END; diff --git a/registry/migrations/008_unit_tests.sql b/registry/migrations/008_unit_tests.sql new file mode 100644 index 00000000..6ac1f20a --- /dev/null +++ b/registry/migrations/008_unit_tests.sql @@ -0,0 +1,37 @@ +-- 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;