Bootstrap tamq local tmux agent message queue
Some checks failed
tamq-ci / test (push) Failing after 36s
Some checks failed
tamq-ci / test (push) Failing after 36s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02f34-ead4-7a60-85cd-d7f08e22fa0e
This commit is contained in:
parent
521bbe5afc
commit
4d915a2617
58 changed files with 1882 additions and 1 deletions
31
tests/test_replay.py
Normal file
31
tests/test_replay.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import json
|
||||
|
||||
from tamq.cli import main
|
||||
from tamq.store import Store
|
||||
|
||||
|
||||
def test_replay_reports_batch(tmp_path, monkeypatch, capsys):
|
||||
source = tmp_path / "messages.jsonl"
|
||||
source.write_text(json.dumps({"message_id": "old-1", "sender_repo": "a", "target_repo": "b", "body": "hello"}) + "\n")
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
assert main(["replay", str(source)]) == 0
|
||||
output = json.loads(capsys.readouterr().out)
|
||||
assert output["batch_id"].startswith("replay-")
|
||||
assert output["count"] == 1
|
||||
|
||||
|
||||
def test_replay_preserves_endpoint(tmp_path, monkeypatch, capsys):
|
||||
source = tmp_path / "messages.jsonl"
|
||||
source.write_text(json.dumps({"sender_repo": "a", "target_repo": "b", "body": "hello", "endpoint_id": "tmux-amq-42"}) + "\n")
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
assert main(["replay", str(source)]) == 0
|
||||
row = Store(tmp_path / "state" / "tamq.sqlite3").list()[0]
|
||||
assert row["endpoint_id"] == "tmux-amq-42"
|
||||
|
||||
|
||||
def test_replay_rejects_bad_json(tmp_path, monkeypatch, capsys):
|
||||
source = tmp_path / "bad.jsonl"
|
||||
source.write_text("not-json\n")
|
||||
monkeypatch.setenv("TAMQ_STATE_DIR", str(tmp_path / "state"))
|
||||
assert main(["replay", str(source)]) == 2
|
||||
assert "cannot replay" in capsys.readouterr().err
|
||||
Loading…
Add table
Add a link
Reference in a new issue