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
29 lines
960 B
Python
29 lines
960 B
Python
import json
|
|
|
|
from tamq.cli import main
|
|
from tamq.store import Store
|
|
|
|
|
|
def test_purge_dry_run_does_not_delete(tmp_path, monkeypatch, capsys):
|
|
state = tmp_path / "state"
|
|
monkeypatch.setenv("TAMQ_STATE_DIR", str(state))
|
|
store = Store(state / "tamq.sqlite3")
|
|
store.add("a", "b", "body")
|
|
store.close()
|
|
assert main(["purge"]) == 0
|
|
assert "Dry run" in capsys.readouterr().out
|
|
store = Store(state / "tamq.sqlite3")
|
|
assert len(store.list()) == 1
|
|
|
|
|
|
def test_purge_confirmed_deletes(tmp_path, monkeypatch, capsys):
|
|
state = tmp_path / "state"
|
|
monkeypatch.setenv("TAMQ_STATE_DIR", str(state))
|
|
store = Store(state / "tamq.sqlite3")
|
|
store.add("a", "b", "body")
|
|
store.db.execute("UPDATE messages SET created_at=created_at-400*86400")
|
|
store.db.commit()
|
|
store.close()
|
|
assert main(["purge", "--yes"]) == 0
|
|
assert "Purged" in capsys.readouterr().out
|
|
assert len(Store(state / "tamq.sqlite3").list()) == 0
|