Each done build's end is published as build.ended.<module>.<fingerprint> (escaped) with the module, fingerprint, made digests, kept-on and branch, where the log entry is written. Builds: design 47 G §379, A-96 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
33 lines
1.2 KiB
Go
33 lines
1.2 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", 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 },
|
|
"failed": func(e *BuildLogEntry) { e.Outcome = BuildFailed },
|
|
"no fp": func(e *BuildLogEntry) { e.FP = "" },
|
|
} {
|
|
c := e
|
|
mut(&c)
|
|
if _, ok := BuildEndedOf(c); ok {
|
|
t.Errorf("%s: an event", name)
|
|
}
|
|
}
|
|
}
|