diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 45b8e01f8..1514b3383 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -20,6 +20,7 @@ import ( stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/process" + "mesh-delivery-builder/internal/build" "mesh-delivery-builder/internal/versions" ) @@ -666,6 +667,39 @@ func (e ansEntry) Revision() uint64 { return 1 } func (e ansEntry) Value() []byte { return e.value } func (e ansEntry) Operation() jetstream.KeyValueOp { return jetstream.KeyValuePut } +// noAskKnown is a builder none of whose lanes waits: it records the keys asked again and builds, announces and releases nothing. +type noAskKnown struct{ asked []string } + +func (n *noAskKnown) AskAgain(key, _ string) []string { n.asked = append(n.asked, key); return nil } +func (n *noAskKnown) BuildAgain(context.Context, string, string, string, string, time.Duration) build.BuildAgainResult { + return build.BuildAgainResult{} +} +func (n *noAskKnown) AnnounceAgain(context.Context, string, string, string, string) build.BuildAgainResult { + return build.BuildAgainResult{} +} +func (n *noAskKnown) Release(context.Context, string, string, string, string) string { return "" } + +// TestAReserveDoneReAskIsNoAskTheBuilderKnows: design 47 H2 H-A-706 (DQ-39), AC-B14b — builder_reserve_done is gone, so a re-ask of its mode +// reserve-done is no hand act of a version: it is answered as any ask of a key no lane of the builder waits on, and writes no reservation. +func TestAReserveDoneReAskIsNoAskTheBuilderKnows(t *testing.T) { + kv := &ansKV{wrote: make(chan []byte, 1)} + raw, _ := json.Marshal(build.ReAsk{V: 1, Why: "a test asks it", By: "op@node", At: time.Now(), Mode: "reserve-done", Name: "m", Version: "0.1.0"}) + b := &noAskKnown{} + reAsked(context.Background(), b, versions.Acts{}, nil, kv, ansEntry{key: "m.fp", value: raw}, t.Logf) + var got build.ReAsk + select { + case v := <-kv.wrote: + if err := json.Unmarshal(v, &got); err != nil { + t.Fatal(err) + } + default: + t.Fatal("the re-ask was not answered") + } + if !strings.Contains(got.Answer, "no ask of this key waits in this builder") || !slices.Equal(b.asked, []string{"m.fp"}) || got.Answered.IsZero() { + t.Errorf("a re-ask of mode reserve-done answered %q (asked %v), want it answered as an ask no lane waits on", got.Answer, b.asked) + } +} + // TestARegistrysRecordEndsOrMovesAPublish: design 47 H H-A-274 — the artifacts a registry's record holds with the built digest are // marked published from it and package-published is said, as a heard published would; H-A-275 — a done build whose number a // registry holds at another digest (H-A-279) has its number withdrawn, raises version-held-elsewhere naming both digests, and is