Files
mesh-sdk/go/served_test.go
T
jschoubben b9911dc1c1 Start the puller's capacity watch once Serve has the runtime's channel, since a build module pulls before it serves (issue 1887)
A watch asked before Serve is refused, which would have left every build
module on its settings file again. stdio.Served closes when Serve has the
channel; WatchConfigServed waits on it, and Pull starts the watch beside its
loop.
2026-10-25 17:26:10 +01:00

28 lines
658 B
Go

package stdio
import (
"io"
"sync"
"testing"
"time"
)
// 1887/AC-wake: code started before Serve (a build puller's watch of its capacity) waits on Served, which closes once
// Serve has the runtime's channel, so it asks the runtime then and not before.
func TestServedClosesOnceServing(t *testing.T) {
served, servedOnce = make(chan struct{}), sync.Once{}
select {
case <-Served():
t.Fatal("Served closed before Serve")
default:
}
inR, inW := io.Pipe()
defer inW.Close()
go func() { _ = ServeOn("", nil, inR, io.Discard) }()
select {
case <-Served():
case <-time.After(2 * time.Second):
t.Fatal("Served did not close once serving")
}
}