Files
mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient/client_test.go
T
jschoubben 71a35a6376 MV1: move contracts and sdk under modules/, importers follow
The delivery repository's contracts and SDK live under modules/ as
mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths
renamed to match the folders (the TypeScript names already did), and
every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools
and mesh-sdk follows in the same group: a design as it should be, one
path per module, checked by the group's check building every importer.

Builds: design 47 G §427, §88

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 05:09:56 +01:00

49 lines
2.4 KiB
Go

package meshpipelinerunnerclient
import (
"testing"
seat "git.novox.be/novox/mesh-delivery/modules/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)
}
}