test(swarm): wait for inbox listener before send
Some checks are pending
ci / test (macos-latest) (push) Waiting to run
ci / test (ubuntu-latest) (push) Waiting to run
ci / test (windows-latest) (push) Waiting to run

This commit is contained in:
patriceckhart 2026-06-17 16:38:56 +02:00
parent d5d0754b13
commit 5a4e4923f2

View file

@ -102,6 +102,7 @@ func TestRunSwarmNewSpawnsAgent(t *testing.T) {
func TestRunSwarmSendDeliversToAgentInbox(t *testing.T) {
root := t.TempDir()
recv := make(chan string, 4)
ready := make(chan error, 1)
f := swarm.New(swarm.Config{
Root: root,
RepoRoot: root,
@ -112,6 +113,7 @@ func TestRunSwarmSendDeliversToAgentInbox(t *testing.T) {
// something to talk to. The runner-test stubs do the
// same; this is the minimum to exercise the wire.
ln, err := swarm.Listen(a.InboxPath)
ready <- err
if err != nil {
return err
}
@ -138,6 +140,14 @@ func TestRunSwarmSendDeliversToAgentInbox(t *testing.T) {
if err != nil {
t.Fatalf("spawn: %v", err)
}
select {
case err := <-ready:
if err != nil {
t.Fatalf("listen: %v", err)
}
case <-time.After(5 * time.Second):
t.Fatal("timed out waiting for agent inbox listener")
}
// Run /swarm send <id> <text...>. The dispatcher would have
// already strings.Fields-ed the input; mirror that here.