From d6b9cef9d00553ab2030871f9bcb14c9e10ab6c1 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 23 Oct 2026 17:19:38 +0200 Subject: [PATCH] Prove a check ask's digest is the digest tool's answer in the call, so the checker keys kept verdicts by it (issue 1917) --- .../cmd/mesh-build-go/asks_test.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/asks_test.go b/modules/mesh-build-go/cmd/mesh-build-go/asks_test.go index c9d34364..5f94f37a 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/asks_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/asks_test.go @@ -148,3 +148,33 @@ func TestManifestClaimsTheGoBuildSeatAndReadsItsCapacity(t *testing.T) { } func m0() *Module { return &Module{Node: "ace", Capacity: func() int { return 0 }} } + +// 1917: a check ask's digest is the digest tool's own body, which answers the packages in the call (no step key): the +// ask's level carries the digest, so the checker keys the kept verdicts by it. +func TestACheckAsksDigestIsTheToolsAnswerInTheCall(t *testing.T) { + m := &Module{Node: "ace"} + for _, s := range m.StepTools() { + if s.Name == "build_go_digest" && s.Long { + t.Fatal("build_go_digest is a long step: its answer would be a step key, not the digest") + } + } + var calls []string + steps := fakeSteps(&calls) + for i := range steps { + if steps[i].Name == "build_go_digest" { + steps[i].Run = func(ctx context.Context, args map[string]any) (any, error) { + return map[string]any{"level": "unit", "packages": map[string]string{"x/a": "d1"}}, nil + } + } + } + ask := m.askSteps(steps) + a := delivery.StepAsk{ID: buildstep.NewID(), Kind: delivery.AskCheck, Language: delivery.AskGo, Asker: "mesh-delivery-checker", + At: time.Now(), Check: &delivery.CheckJob{Fetch: map[string]any{"repository": "novox/x", "commit": askCommit}, Levels: []string{delivery.LevelUnit}}} + out, err := buildstep.RunAsk(context.Background(), ask, a) + if err != nil { + t.Fatal(err) + } + if l := out.(delivery.CheckAnswer).Levels; len(l) != 1 || !strings.Contains(string(l[0].Digest), `"x/a":"d1"`) { + t.Fatalf("levels = %+v, want the digest's packages", l) + } +}