publishconformance: the cases of a one-part publish made while the build runs, reserved with no digest yet among them (A-490j)

Builds: design 47 G A-490j, A-490a

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-19 21:33:46 +01:00
parent 7de5814a26
commit 95b4b308ad
@@ -72,3 +72,60 @@ func Run(t *testing.T, fresh func(t *testing.T) Bed) {
}
})
}
// What the builder's reservation holds of the artifact a case publishes.
type Reservation int
const (
// NoDigestYet is an artifact whose build has not recorded its digest (the build runs, design 47 G §369, A-415).
NoDigestYet Reservation = iota + 1
// SameDigest is the digest of the file the case publishes.
SameDigest
// OtherDigest is another digest.
OtherDigest
)
// ReservedBed is one holder under test for the one-part publish a build module makes while it builds, fresh for a case. The
// holder's check asks the builder's reservation through its real Reserved check; the bed answers as the builder's verb `reserved`
// does.
type ReservedBed struct {
// Reserve makes the builder hold the case's name at its version as reserved, its artifact as r says. A case that never calls
// it has the builder hold no reservation.
Reserve func(r Reservation)
// PublishWhole sends the one-part publish of the case's file (its own digest) and reports what the holder did.
PublishWhole func() Outcome
}
// RunReserved runs the cases of a publish made while the build runs, over beds made by fresh (design 47 G A-490j): the builder
// records a build's digests only when it ends, so a reserved artifact naming no digest yet takes the publish.
func RunReserved(t *testing.T, fresh func(t *testing.T) ReservedBed) {
t.Helper()
for _, c := range []struct {
name string
reserve Reservation // 0: nothing reserved
ok bool
words string
}{
{name: "reserved, no digest yet: published", reserve: NoDigestYet, ok: true},
{name: "reserved with the digest: published", reserve: SameDigest, ok: true},
{name: "reserved for another digest: refused, naming the reservation", reserve: OtherDigest, words: "did not reserve"},
{name: "nothing reserved: refused", words: "did not"},
} {
t.Run("a one-part publish while the build runs, "+c.name, func(t *testing.T) {
b := fresh(t)
if c.reserve != 0 {
b.Reserve(c.reserve)
}
o := b.PublishWhole()
if c.ok {
if o.Err != nil || o.Event != "published" {
t.Fatalf("answered %+v; want no error and published said", o)
}
return
}
if o.Err == nil || o.Event == "published" || !strings.Contains(o.Err.Error()+o.Reason, c.words) {
t.Fatalf("answered %+v; want refused, with %q in its words, and nothing published", o, c.words)
}
})
}
}