From d4977d9c9d673dc6c655f5f6af64aff40df4809c Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 23 Oct 2026 16:11:31 +0200 Subject: [PATCH] Start the checker whole with the assigner's verdict on the bus and read its line, the level 1297/AC3 asks (issue 1297, review round 1 item 2) --- .../composition_line_integration_test.go | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 modules/mesh-delivery-checker/cmd/mesh-delivery-checker/composition_line_integration_test.go diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/composition_line_integration_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/composition_line_integration_test.go new file mode 100644 index 0000000..e41c96c --- /dev/null +++ b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/composition_line_integration_test.go @@ -0,0 +1,63 @@ +//go:build integration + +package main + +import ( + "strings" + "testing" + + "github.com/nats-io/nats.go/jetstream" + + "git.novox.be/novox/mesh-sdk/go/delivery" +) + +// assignerWrote raises the assigner's compositions bucket, the assigner online in the watchman's presence, and its verdict +// under the check's key, as the assigner leaves them on the bus. +func (b *bed) assignerWrote(t *testing.T, key string, v delivery.CompositionVerdict) { + t.Helper() + kv, err := b.js.CreateKeyValue(b.ctx, jetstream.KeyValueConfig{Bucket: delivery.AssignerCompositionsBucket, History: delivery.AssignerCompositionsHistory}) + if err != nil { + t.Fatal(err) + } + pkey, _ := delivery.PresencePartKey(delivery.AssignerModule, "novox") + on, _ := delivery.EncodePresence(delivery.Presence{Online: true}) + if _, err := b.buckets[delivery.PresenceBucket].Put(b.ctx, pkey, on); err != nil { + t.Fatal(err) + } + data, err := delivery.EncodeCompositionVerdict(v) + if err != nil { + t.Fatal(err) + } + if _, err := kv.Put(b.ctx, key, data); err != nil { + t.Fatal(err) + } +} + +// 1297/AC3: started whole with the assigner's verdict on the bus, the checker's line says the composition's verdict, not +// "not yet run": a pass names its machine, a fail fails the check with the assigner's words. +func TestTheCheckersLineSaysTheAssignersComposition(t *testing.T) { + for _, c := range []struct { + state, owed, words string + }{ + {delivery.CompositionPass, "success", "composition passed"}, + {delivery.CompositionFail, "failure", "g14 runs web, which the change removes from its source"}, + } { + b := startBed(t) + key := b.candidate(t, "feat/x", pull(repo, 7, head1)) + group, heads, _ := delivery.ParseCheckerVerdictKey(key) + v := delivery.CompositionVerdict{Group: group, Heads: heads, State: c.state, SDK: "v0.1.14-x", Machines: []string{"g14"}} + if c.state == delivery.CompositionFail { + v.Machine, v.Words = "g14", c.words + } + b.assignerWrote(t, key, v) + b.start(t, nil) + got := b.verdict(t, key, ended) + if got.Composition == nil || got.Composition.State != c.state { + t.Fatalf("%s: the verdict's composition is %+v", c.state, got.Composition) + } + o := b.owed(t, 7, head1, c.owed) + if !strings.Contains(o.Text, c.words) || strings.Contains(o.Text, "not yet run") { + t.Errorf("%s: the line says %q", c.state, o.Text) + } + } +}