Files
mesh-sdk/go/process/no_serve_test.go
T
jschoubben 8afc3ebdf3
mesh/delivery merged: source.main moved to novox/mesh-sdk@27da949140c6
mesh/check being carried to 8afc3ebdf371 on 93e0a7b50d90 | from 27da949140c6
Revert G's mesh-sdk merge (#189): G merged half, and today's validator refuses G's delivery parts
The group feat/47-G-join11 merged 3 of 17 members on 2026-11-13; G's mesh-sdk alone on main breaks 25 trunk
modules. The operator chose to put the order right: a reader release first, then G whole. This restores main
to 8fbba810 exactly.

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-13 11:12:48 +01:00

38 lines
1.3 KiB
Go

package process
import (
"reflect"
"testing"
"github.com/nats-io/nats.go"
)
// 1171/AC3: it offers no Serve and no way to serve a tool — a process reaches the bus only as itself, and
// never answers a call. Checked by reflection over *Conn's whole method set and field list, so a later
// addition cannot bring one back without this test naming it.
func TestConnOffersNoServeAndExposesNoRawConnection(t *testing.T) {
ptrType := reflect.TypeOf(&Conn{})
for _, forbidden := range []string{"Serve", "ServeOn", "Handle", "Subscribe", "Respond", "Answer"} {
if _, ok := ptrType.MethodByName(forbidden); ok {
t.Errorf("*Conn has a method %s: a process offers no way to serve a tool", forbidden)
}
}
natsConnType := reflect.TypeOf(&nats.Conn{})
structType := reflect.TypeOf(Conn{})
for i := 0; i < structType.NumField(); i++ {
f := structType.Field(i)
if f.IsExported() && (f.Type == natsConnType || f.Type == natsConnType.Elem()) {
t.Errorf("Conn exposes its raw connection through the exported field %s", f.Name)
}
}
for i := 0; i < ptrType.NumMethod(); i++ {
m := ptrType.Method(i)
for o := 0; o < m.Type.NumOut(); o++ {
if m.Type.Out(o) == natsConnType || m.Type.Out(o) == natsConnType.Elem() {
t.Errorf("*Conn.%s returns the raw *nats.Conn", m.Name)
}
}
}
}