Some checks failed
tamq-ci / test (push) Failing after 5s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
27 lines
930 B
Python
27 lines
930 B
Python
from tamq.cli import main
|
|
from tamq.store import Store
|
|
|
|
|
|
def test_retry_cli_resets_only_terminal_failures(tmp_path, monkeypatch, capsys):
|
|
state = tmp_path / "state"
|
|
monkeypatch.setenv("TAMQ_STATE_DIR", str(state))
|
|
store = Store(state / "tamq.sqlite3")
|
|
failed = store.add("a", "b", "failed")
|
|
pending = store.add("a", "b", "pending")
|
|
store.db.execute(
|
|
"UPDATE messages SET state='failed',attempt_count=4,last_failure_reason='OSError' "
|
|
"WHERE message_id=?",
|
|
(failed,),
|
|
)
|
|
store.db.commit()
|
|
store.close()
|
|
|
|
assert main(["retry", failed]) == 0
|
|
assert capsys.readouterr().out.strip() == failed
|
|
reopened = Store(state / "tamq.sqlite3")
|
|
assert reopened.message(failed)["state"] == "pending"
|
|
assert reopened.message(failed)["attempt_count"] == 0
|
|
reopened.close()
|
|
|
|
assert main(["retry", pending]) == 1
|
|
assert "not failed" in capsys.readouterr().err
|