Files
mesh-delivery/modules/mesh-delivery-builder/builds/ended_test.go
T
jschoubben 8f43d0ecdf AS23: build.ended says a failed end too; a hold under rule 1 says how the build stands
The builder's build.ended is said for a failed build as well (outcome, error whole);
the assigner's rule-1 hold reads "the build of M at F failed: <error>" from it and
"is being built" while none is heard. The assigner's reads of the builder's builds
bucket stay (see the report: a restarted assigner holds no ends heard).

Builds: design 47 G §575, §568, A-162 (survey AS23)
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 05:43:15 +01:00

43 lines
1.7 KiB
Go

package builds
import (
"reflect"
"testing"
)
// Design 47 G §379, A-96: a done build's end is the event build.ended, its subject escaped by module and fingerprint; any other
// entry is none.
func TestADoneBuildsEndIsTheEventBuildEnded(t *testing.T) {
made := []BuiltArtifact{{Name: "program", Kind: "program", Digest: "sha256:1"}}
e := BuildLogEntry{Event: BuildEndedEvent, Outcome: BuildDone, Module: "node-engine", FP: "src2:a", Ref: "cand", KeptOn: "ace", Made: made}
got, ok := BuildEndedOf(e)
want := BuildEnded{Module: "node-engine", Fingerprint: "src2:a", Outcome: BuildDone, Made: map[string]string{"program": "sha256:1"}, KeptOn: "ace", Branch: "cand"}
if !ok || !reflect.DeepEqual(got, want) {
t.Errorf("event = %+v, %v", got, ok)
}
if n := BuildEndedEventName("node-engine", "src2:a"); n != "build.ended.node-engine.src2=3aa" {
t.Errorf("event name = %q", n)
}
for name, mut := range map[string]func(*BuildLogEntry){
"started": func(e *BuildLogEntry) { e.Event = BuildStartedEvent },
"queued": func(e *BuildLogEntry) { e.Outcome = BuildQueued },
"no fp": func(e *BuildLogEntry) { e.FP = "" },
} {
c := e
mut(&c)
if _, ok := BuildEndedOf(c); ok {
t.Errorf("%s: an event", name)
}
}
}
// Design 47 G §575, A-162: a failed build's end is said too, with its outcome and its error whole.
func TestAFailedBuildsEndIsSaidWithItsError(t *testing.T) {
e := BuildLogEntry{Event: BuildEndedEvent, Outcome: BuildFailed, Module: "web", FP: "src2:b", Error: "transport fault: no responders at mesh-build-go"}
got, ok := BuildEndedOf(e)
want := BuildEnded{Module: "web", Fingerprint: "src2:b", Outcome: BuildFailed, Error: e.Error, Made: map[string]string{}}
if !ok || !reflect.DeepEqual(got, want) {
t.Errorf("event = %+v, %v", got, ok)
}
}