Some checks failed
tamq-ci / test (push) Failing after 6s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
import json
|
|
import sqlite3
|
|
|
|
from tamq.store import Store
|
|
|
|
|
|
def test_message_history_and_jsonl(tmp_path):
|
|
store = Store(tmp_path / "tamq.sqlite3")
|
|
message_id = store.add("net-kingdom", "railiance-platform", "hello")
|
|
rows = store.list(target="railiance-platform")
|
|
assert rows[0]["message_id"] == message_id
|
|
output = tmp_path / "messages.jsonl"
|
|
store.export(rows, output)
|
|
assert json.loads(output.read_text())["body"] == "hello"
|
|
assert store.db.execute("PRAGMA journal_mode").fetchone()[0] == "wal"
|
|
store.close()
|
|
|
|
|
|
def test_store_migrates_legacy_endpoint_rows_to_manual_delivery(tmp_path):
|
|
path = tmp_path / "legacy.sqlite3"
|
|
db = sqlite3.connect(path)
|
|
db.executescript(
|
|
"""
|
|
CREATE TABLE metadata (key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
INSERT INTO metadata VALUES('schema_version', '1');
|
|
CREATE TABLE endpoints (
|
|
endpoint_id TEXT PRIMARY KEY,
|
|
pid INTEGER NOT NULL,
|
|
session TEXT NOT NULL,
|
|
repos TEXT NOT NULL,
|
|
connected_at REAL NOT NULL,
|
|
disconnected_at REAL
|
|
);
|
|
INSERT INTO endpoints VALUES('legacy', 1, 'tamq', '[\"repo\"]', 1, NULL);
|
|
"""
|
|
)
|
|
db.commit()
|
|
db.close()
|
|
|
|
store = Store(path)
|
|
assert store.endpoints()[0]["delivery_mode"] == "manual"
|
|
assert store.db.execute(
|
|
"SELECT value FROM metadata WHERE key='schema_version'"
|
|
).fetchone()[0] == "2"
|
|
store.close()
|