Files
mesh-catalog/modules/mesh-issues/cmd/mesh-issues/conditionkey_test.go
T
jschoubben 98d494619f
mesh/merge-gate pass: builds mesh-issues → novox; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery delivered
mesh-issues: take a delivery's id as mesh-delivery forms it, owner/repo@commit (hq issue 475)
The delivery link's own pattern refused the slash and the @ every delivery id
carries, so no delivery could be linked either. Mirror mesh-delivery's IDOf.
2026-10-11 19:24:23 +02:00

92 lines
3.6 KiB
Go

package main
import (
"strings"
"testing"
)
// A condition link takes every key the controller raises (novox/hq issue 475). The keys are real: the delivery's
// as `mesh-controller.status` named it when the link was refused, the others as `mesh-controller.conditions`
// answered on 2026-10-11.
var realConditionKeys = []string{
"delivery.novox/mesh-controller_d2e9dc61590f.stalled", // a delivery's id carries its repository, owner/name
"machine.novox.telegram.telegram-token.secret-given",
"module.openrazer.shanks.relogin-needed",
"mesh.hand-acts.plans_go.healer-wanted", // a space in the id, made `_` by the controller
"delivery.leaf.over-budget",
}
func TestAConditionLinkTakesEveryKeyTheControllerRaises(t *testing.T) {
h := newHarness(t)
n := h.open(t, "a delivery stalls", "mesh-catalog")
for _, k := range realConditionKeys {
if _, err := h.Link(LinkAsk{Number: n, Kind: LinkCondition, Target: k}); err != nil {
t.Errorf("%s: %v", k, err)
}
}
got, err := h.Tracking([]string{realConditionKeys[0]})
if err != nil {
t.Fatal(err)
}
if is := got.Conditions[realConditionKeys[0]]; len(is) != 1 || is[0].Number != n || got.Said != "Issues track 1 condition." {
t.Fatalf("the delivery's condition is not said tracked: %+v", got)
}
}
// What the controller never raises is refused, so a link never names a condition that cannot exist.
func TestAConditionLinkRefusesWhatTheControllerNeverRaises(t *testing.T) {
for _, k := range []string{
"",
"delivery.stalled", // no id: a key is scope, id and kind
"weather.novox.rain", // no scope the controller knows
"machine..secret-given", // an empty token
"machine.novox.secret given", // a space the controller makes `_`
"machine.novox:1.secret-given", // a colon the controller makes `_`
"delivery.novox/mesh-controller@d2e9dc61590f.stalled", // `@` too
"machine.*.silent", // a wildcard on the bus
"machine.>", // a wildcard on the bus
"machine.ace.silent\nmore", // a second line
"machine." + strings.Repeat("a", 300) + ".silent",
} {
if _, err := checkTarget(LinkCondition, k); err == nil {
t.Errorf("%q was taken as a condition's key", k)
}
}
}
// A delivery link takes every id mesh-delivery gives (novox/hq issue 475): the ids are real, as
// `mesh-delivery.deliveries` answered on 2026-10-11.
var realDeliveryIDs = []string{
"novox/mesh-controller@0f853e93fa11",
"novox/mesh-catalog@7714f164c33f",
"novox/hq@34bdb1a34f5a",
"novox/mesh-media-catalog@dd3f0abb3f78",
"novox/mesh-tools@82aefe1988c2",
}
func TestADeliveryLinkTakesEveryIdMeshDeliveryGives(t *testing.T) {
h := newHarness(t)
n := h.open(t, "a delivery stalls", "mesh-catalog")
for _, id := range realDeliveryIDs {
if _, err := h.Link(LinkAsk{Number: n, Kind: LinkDelivery, Target: id}); err != nil {
t.Errorf("%s: %v", id, err)
}
}
for _, id := range []string{
"",
"mesh-controller@0f853e93fa11", // no owner
"novox/mesh-controller", // no commit
"novox/mesh-controller@0f853e93fa11aa", // more than twelve characters of the commit
"Novox/Mesh-Controller@0f853e93fa11", // mesh-delivery lower-cases the repository
"novox/mesh-controller@0F853E93FA11", // a commit is lower-case hex
"novox/mesh-controller@main", // a branch, not a commit
"novox/mesh/controller@0f853e93fa11", // a repository is owner/name, no deeper
"novox/mesh-controller_d2e9dc61590f", // a condition key's form of it, not the id
"novox/mesh-controller@0f853e93fa11\nmore", // a second line
} {
if _, err := checkTarget(LinkDelivery, id); err == nil {
t.Errorf("%q was taken as a delivery's id", id)
}
}
}