Files
mesh-catalog/modules/systemd-networkd/cmd/uplink-tools/manager_test.go
T
jochen a8dfe343a2 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
2026-11-24 21:06:34 +01:00

43 lines
1.6 KiB
Go

package main
import "testing"
// systemd-networkd's word on each link's names, read from `networkctl status --all`.
func TestNetworkctlIsReadPerLink(t *testing.T) {
out := `● 1: lo
Link File: n/a
Network File: n/a
State: carrier (unmanaged)
● 2: eth0
Link File: /usr/lib/systemd/network/99-default.link
Network File: /etc/systemd/network/20-wired.network
State: routable (configured)
Address: 198.51.100.7
Gateway: 198.51.100.1
DNS: 198.51.100.53
198.51.100.54
Search Domains: example.net lab.example
Activation Policy: up
`
links := parseNetworkctl(out)
eth := links["eth0"]
if len(links) != 1 || len(eth.Servers) != 2 || eth.Servers[1] != "198.51.100.54" || len(eth.Domains) != 2 ||
eth.State != "routable (configured)" || eth.Manager != "systemd-networkd" {
t.Fatalf("read %+v", links)
}
}
// systemd-networkd serves the seat's two verbs and nothing of its own: no subcommand, no tool, no work at its start
// (design 08 sign-in-page §11, §28).
func TestNetworkdServesTheSeatsVerbsAlone(t *testing.T) {
own := holder(Machine{})
if len(own.Commands) != 0 || len(own.Tools) != 0 || own.Start != nil {
t.Fatalf("systemd-networkd adds %+v", own)
}
served := tools(Machine{}, own)
if len(served) != 2 || served[0].Name != "node-uplink.resolvers" || served[1].Name != "node-uplink.links" {
t.Fatalf("served %v", served)
}
}