mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-26 13:26:33 +02:00
test(swarm): wait for inbox listener before send
This commit is contained in:
parent
d5d0754b13
commit
5a4e4923f2
1 changed files with 10 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue