Builds: design 47 G §73, §74, §332 (every subject built and parsed back; group-ended under branch and group with no module part). The rule Passed of the dev branch is not built: no line of the contracts part names it. Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
49 lines
2.4 KiB
Go
49 lines
2.4 KiB
Go
package meshpipelinerunnerclient
|
|
|
|
import (
|
|
"testing"
|
|
|
|
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshpipelinerunner"
|
|
)
|
|
|
|
// A-D7: the subject carries the module, the branch and the commit or group, each escaped as a key's name is, and is
|
|
// read back (design 47 *Health and going back*); a body naming nothing is refused.
|
|
func TestSubjectsAndBodies(t *testing.T) {
|
|
s := Subject(seat.EventPipelineEnded, "nats", "release.1", "feat/47-G")
|
|
if s != "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.release=2e1.feat/47-G" {
|
|
t.Errorf("subject %s", s)
|
|
}
|
|
if of, err := Parse(s); err != nil || of != (Of{seat.EventPipelineEnded, "nats", "release.1", "feat/47-G"}) {
|
|
t.Errorf("parse %s: %+v, %v", s, of, err)
|
|
}
|
|
for _, bad := range []string{"not.an.event.subject", "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.main",
|
|
"mesh.seat.mesh-pipeline-runner.event.no-such.nats.main.c1", "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.nats.ma=zz.c1"} {
|
|
if _, err := Parse(bad); err == nil {
|
|
t.Errorf("%s parsed", bad)
|
|
}
|
|
}
|
|
// design 47 G §332: a group's end is said under the branch and the group, with no module.
|
|
gs := GroupEndedSubject("main", "registry.1966")
|
|
if gs != "mesh.seat.mesh-pipeline-runner.event.group-ended.main.registry=2e1966" {
|
|
t.Errorf("group-ended subject %s", gs)
|
|
}
|
|
if of, err := Parse(gs); err != nil || of != (Of{Event: seat.EventGroupEnded, Branch: "main", CommitOrGroup: "registry.1966"}) {
|
|
t.Errorf("parse %s: %+v, %v", gs, of, err)
|
|
}
|
|
if _, err := Parse("mesh.seat.mesh-pipeline-runner.event.group-ended.nats.main.g1"); err == nil {
|
|
t.Error("a group-ended with a module part parsed")
|
|
}
|
|
if _, err := PipelineEnded([]byte(`{"v":1,"pipeline":"main.12.nats","module":"nats","branch":"main","commit":"c1","outcome":"passed","steps":[]}`)); err != nil {
|
|
t.Error(err)
|
|
}
|
|
if _, err := PipelineEnded([]byte(`{"v":1,"module":"nats"}`)); err == nil {
|
|
t.Error("a pipeline-ended naming no pipeline was taken")
|
|
}
|
|
if _, err := GroupEnded([]byte(`{"v":1,"group":"g","branch":"main","outcome":"passed","pipelines":[{"module":"nats"}]}`)); err == nil {
|
|
t.Error("a group-ended with a pipeline naming nothing was taken")
|
|
}
|
|
if e, err := StepEnded([]byte(`{"v":1,"pipeline":"p","module":"nats","branch":"main","commit":"c1","result":{"step":"unit","status":"required","outcome":"passed","rerun":true,"by":"operator@shanks"}}`)); err != nil || !e.Result.Rerun {
|
|
t.Errorf("step-ended: %+v, %v", e, err)
|
|
}
|
|
}
|