mesh-cli requires the console's endpoint and writes its address
nox now reaches the mesh through this machine's console, so the module requires mcp-endpoint and writes the bound address to /etc/mesh-cli/console rather than trusting a fixed port. No invokes: mesh-cli has no bus account, and one nothing dials would only be minted. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -6,11 +6,11 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// **The archive places exactly one file, /usr/local/bin/mesh-cli** (review of novox/hq ADR 0272): one archive
|
||||
// **The archive places exactly one file, /usr/local/bin/mesh-cli**, and the console's address is one file more (review of novox/hq ADR 0272): one archive
|
||||
// resource, unpacking one artifact into /usr/local/bin, and that artifact a compiled Go bundle — the builder writes
|
||||
// such a bundle as its binary alone (`go build -o <out>/<binary>`), named mesh-cli — with nothing the runtime would
|
||||
// load or put beside it. A second file in the bundle, or a second resource writing there, fails here.
|
||||
func TestTheArchivePlacesExactlyOneFile(t *testing.T) {
|
||||
func TestTheArchivePlacesExactlyOneFileAndTheConsolesAddressOne(t *testing.T) {
|
||||
raw, err := os.ReadFile("../../module.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -24,12 +24,24 @@ func TestTheArchivePlacesExactlyOneFile(t *testing.T) {
|
||||
if err := json.Unmarshal(raw, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(m.Resources) != 1 {
|
||||
t.Fatalf("the module declares %d resources; it places one file", len(m.Resources))
|
||||
// Beside the program, one directory and one file: the console's address, from the mcp-endpoint it requires
|
||||
// (novox/hq issue 1126). Nothing else.
|
||||
var r map[string]any
|
||||
for _, res := range m.Resources {
|
||||
switch {
|
||||
case res["type"] == "archive":
|
||||
if r != nil {
|
||||
t.Fatalf("two archives: %v", res)
|
||||
}
|
||||
r = res
|
||||
case res["type"] == "directory" && res["path"] == "/etc/mesh-cli":
|
||||
case res["type"] == "file" && res["path"] == consoleFile && res["template"] == "files/console":
|
||||
default:
|
||||
t.Fatalf("the module declares %v beside the program and the console's address", res)
|
||||
}
|
||||
}
|
||||
r := m.Resources[0]
|
||||
if r["type"] != "archive" || r["path"] != "/usr/local/bin" {
|
||||
t.Fatalf("its resource is %v", r)
|
||||
if len(m.Resources) != 3 || r == nil || r["path"] != "/usr/local/bin" {
|
||||
t.Fatalf("its resources are %v", m.Resources)
|
||||
}
|
||||
// The build has a second artifact, the files archive the controller reads the templates back from; it
|
||||
// places no file. The artifact the resource unpacks is the one that does.
|
||||
@@ -66,3 +78,22 @@ func TestTheArchivePlacesExactlyOneFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The console's address is written from the mcp-endpoint the module requires, as claude-code writes it, so it follows
|
||||
// the port node-tools is bound on.
|
||||
func TestTheConsolesAddressIsBoundFromTheEndpoint(t *testing.T) {
|
||||
raw, err := os.ReadFile("../../module.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var m struct {
|
||||
Requires []string `json:"requires"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &m); err != nil || len(m.Requires) != 1 || m.Requires[0] != "mcp-endpoint" {
|
||||
t.Fatalf("it requires %v (%v)", m.Requires, err)
|
||||
}
|
||||
tpl, err := os.ReadFile("../../files/console")
|
||||
if err != nil || string(tpl) != "http://127.0.0.1:${bound:mcp-endpoint:port}/mcp\n" {
|
||||
t.Fatalf("files/console is %q (%v)", tpl, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user