Files
mesh-delivery/contracts/go/clients/meshcatalogkey/key_test.go
T
jschoubben c7ad2477f0 BL6 (key codec): the catalog key's codec is meshcatalogkey, so the builder's builds package reaches no bus
meshcatalogclient imports the new package and keeps two one-line wrappers for the callers of the other parts until
they move to it.

Builds: design 47 G §670, §614 (wiring unchanged)

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 20:26:55 +01:00

40 lines
1015 B
Go

package meshcatalogkey
import (
"go/build"
"strings"
"testing"
)
func TestKeyPartRoundTripsAndRefusesOthers(t *testing.T) {
fp := "src2:" + strings.Repeat("a", 64)
part, err := KeyPart(fp)
if err != nil || part != strings.Repeat("a", 64) {
t.Fatalf("KeyPart = %q, %v", part, err)
}
if back, err := ParseKeyPart(part); err != nil || back != fp {
t.Fatalf("ParseKeyPart = %q, %v", back, err)
}
for _, bad := range []string{"src1:" + strings.Repeat("a", 64), "src2:abc", strings.Repeat("a", 64)} {
if _, err := KeyPart(bad); err == nil {
t.Errorf("KeyPart(%q) accepted", bad)
}
}
if _, err := ParseKeyPart("abc"); err == nil {
t.Error("ParseKeyPart(abc) accepted")
}
}
// Design 47 G §670: the package imports no bus.
func TestThePackageImportsNoBus(t *testing.T) {
p, err := build.ImportDir(".", 0)
if err != nil {
t.Fatal(err)
}
for _, i := range p.Imports {
if strings.Contains(i, "nats") || strings.Contains(i, "/views") {
t.Errorf("meshcatalogkey imports %s", i)
}
}
}