make concurrent
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import cast
|
||||
@@ -31,6 +32,7 @@ def worker(tmp_path: Path, storage: FakeStorage, opencode: FakeOpenCode) -> Work
|
||||
opencode=opencode, # type: ignore[arg-type]
|
||||
dispatcher=SimpleNamespace(), # type: ignore[arg-type]
|
||||
poll_seconds=1,
|
||||
max_concurrent_jobs=2,
|
||||
workspaces_dir=tmp_path,
|
||||
bot_username="agentci",
|
||||
)
|
||||
@@ -66,6 +68,25 @@ async def test_abort_uses_one_shot_fix_workspace(tmp_path: Path) -> None:
|
||||
assert opencode.aborted == {("session", tmp_path / "fix-job" / "repo")}
|
||||
|
||||
|
||||
async def test_run_starts_configured_job_consumers(tmp_path: Path, monkeypatch) -> None:
|
||||
value = worker(tmp_path, FakeStorage(), FakeOpenCode())
|
||||
queues = []
|
||||
|
||||
async def recover() -> None:
|
||||
pass
|
||||
|
||||
async def loop(queue, _stop) -> None:
|
||||
queues.append(queue)
|
||||
|
||||
monkeypatch.setattr(value, "_recover", recover)
|
||||
monkeypatch.setattr(value, "_loop", loop)
|
||||
|
||||
await value.run(asyncio.Event())
|
||||
|
||||
assert queues.count("control") == 1
|
||||
assert queues.count("jobs") == 2
|
||||
|
||||
|
||||
def test_safe_error_is_single_line_and_bounded() -> None:
|
||||
value = _safe_error(RuntimeError("bad\n" + "x" * 2000))
|
||||
assert "\n" not in value
|
||||
|
||||
Reference in New Issue
Block a user