package host import ( "github.com/carlosframework/platform/internal/hostclaim" "testing" ) func TestPlan11RootLaunchRequiresThisBoxAdmittedAsWriter(t *testing.T) { for _, kind := range []string{hostclaim.KindLanding, hostclaim.KindRelocating} { t.Run(kind, func(t *testing.T) { f := newLaunchFixture(t, hostclaim.Op{ID: "operation", Kind: kind, Phase: "probing", Exec: "box-1", Journal: map[string]string{"install_stamp": "11"}}) f.claims.set(func(c *hostclaim.Claim) { c.Holder.WriterBox = "source-box" }) if _, err := f.root.Serve(t.Context(), f.peer, f.req); err == nil { t.Fatal("root launched before the executor admitted its writer session") } if starts, _ := f.units.counts(); starts != 0 { t.Fatal("refused writer caused a unit start") } f.claims.set(func(c *hostclaim.Claim) { c.Holder.WriterBox = "box-1" }) if _, err := f.root.Serve(t.Context(), f.peer, f.req); err != nil { t.Fatalf("admitted executor refused: %v", err) } }) } }