From 95b4b308addef527d2fbd38ba9de7d41c9673d48 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 21:33:46 +0100 Subject: [PATCH] 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 --- .../publishconformance/publishconformance.go | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go index 826bd68b..aa8164bf 100644 --- a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go +++ b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go @@ -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) + } + }) + } +}