Files
mesh-controller/internal/inventory/chain_first_read_lays_out_test.go
T
jschoubben a825a4c904
mesh/merge-gate head a825a4c90446 merged into trunk d3556f452e8c — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head a825a4c90446 merged into trunk d3556f452e8c — pass: its merge-check.sh passed
mesh/delivery delivered
The first read of a chain not laid out lays it out, so no read of the start is refused (issue 1121)
The layout gate is switched on when the stores open (UseChainOpener), before
attachTheChain; a read of the start came first, was refused, and the
controller exited. A read that finds no marker now lays the builds out once,
under a lock, and is refused only when that fails (a process without the
lease).
2026-10-18 14:39:43 +02:00

26 lines
895 B
Go

package inventory
import (
"context"
"testing"
"github.com/novox/mesh-controller/internal/chain"
)
// The first read of a chain that requires the layout lays the builds out itself when it may write, instead of refusing
// the controller's own start (issue 1121, 2026-10-18: the controller exited every five seconds).
func TestTheFirstReadOfAChainNotLaidOutLaysItOut(t *testing.T) {
ctx := context.Background()
inv, c := anInventoryOnTheChain(t)
inv.RequireLayout()
if _, found, _ := c.Builds.GetRaw(ctx, chain.LayoutMarkerKey); found {
t.Fatal("a fresh chain holds the marker already; the test proves nothing")
}
if _, err := inv.theChain(ctx); err != nil {
t.Fatalf("the first read was refused: %v", err)
}
if _, found, err := c.Builds.GetRaw(ctx, chain.LayoutMarkerKey); err != nil || !found {
t.Fatalf("the read did not lay the builds out: found %v, %v", found, err)
}
}