M0 uplink-tools: the holder's own part beside the copies
main.go, still the copy both holders of node-uplink carry, now takes each holder's own subcommands, tools and start work from its manager.go, so networkmanager can add its watcher and tools while systemd-networkd serves the two seat verbs as before. Builds: design 08 sign-in-page §11
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
|
||||
// The node-uplink seat's verbs (novox/hq ADR 0241), every holder's: the resolver file as it is, the mesh's
|
||||
@@ -148,3 +150,30 @@ func TestTheLinksCarryTheirDefaultRouteAndTheirNames(t *testing.T) {
|
||||
t.Fatalf("a manager that does not answer is not said: %+v", answer)
|
||||
}
|
||||
}
|
||||
|
||||
// main.go serves the seat's two verbs first and the holder's own tools after them, and runs a subcommand only when
|
||||
// the holder's manager.go gives it (design 08 sign-in-page §11).
|
||||
func TestTheHoldersOwnPartComesBesideTheSeatsVerbs(t *testing.T) {
|
||||
ran := ""
|
||||
own := holderOwn{
|
||||
Commands: map[string]func([]string) error{"watch": func(args []string) error { ran = strings.Join(args, " "); return nil }},
|
||||
Tools: []stdio.Tool{{Name: "own_tool"}},
|
||||
}
|
||||
var names []string
|
||||
for _, tool := range tools(Machine{}, own) {
|
||||
names = append(names, tool.Name)
|
||||
}
|
||||
if strings.Join(names, " ") != "node-uplink.resolvers node-uplink.links own_tool" {
|
||||
t.Fatalf("served %v", names)
|
||||
}
|
||||
if run, err := command(own, nil); run != nil || err != nil {
|
||||
t.Fatalf("no arguments is the bundle, got a subcommand or %v", err)
|
||||
}
|
||||
if _, err := command(own, []string{"nothing"}); err == nil || !strings.Contains(err.Error(), `"nothing"`) {
|
||||
t.Fatalf("a subcommand the holder has not was taken: %v", err)
|
||||
}
|
||||
run, err := command(own, []string{"watch", "a"})
|
||||
if err != nil || run([]string{"a"}) != nil || ran != "a" {
|
||||
t.Fatalf("the holder's subcommand did not run: %v %q", err, ran)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user