Files
mesh-catalog/modules/networkmanager/cmd/uplink-tools/manager_test.go
T
jochen dc59860541 M2 networkmanager: the watcher hears the rating
uplink-tools watch hears the network manager's PropertiesChanged on the system bus,
keeps sign-in-asked and sign-in-ended as the rules say, at most 256 of them, and
subscribes again when the system bus's socket comes back or on rating-again; nothing
reads the rating on a timer.

Builds: design 08 sign-in-page §12, §14, §20, §21, §22
2026-11-24 21:12:25 +01:00

26 lines
1.1 KiB
Go

package main
import "testing"
// NetworkManager's word on each link's names, read from its terse output.
func TestNmcliIsReadPerDevice(t *testing.T) {
links := parseNmcli("GENERAL.DEVICE:wlp3s0\nGENERAL.STATE:100 (connected)\nIP4.DNS[1]:192.168.1.1\n" +
"IP4.DOMAIN[1]:localdomain\n\nGENERAL.DEVICE:docker0\nGENERAL.STATE:100 (connected (externally))\n\n" +
"GENERAL.DEVICE:vpn0\nGENERAL.STATE:100 (connected)\nIP4.DNS[1]:192.0.2.53\nIP4.DNS[2]:192.0.2.54\n" +
"IP4.DOMAIN[1]:corp.example\n")
if len(links) != 2 || links["wlp3s0"].Servers[0] != "192.168.1.1" || links["wlp3s0"].Domains[0] != "localdomain" ||
len(links["vpn0"].Servers) != 2 || links["vpn0"].Manager != "NetworkManager" {
t.Fatalf("read %+v", links)
}
if _, said := links["docker0"]; said {
t.Fatal("a link with no names was said")
}
}
// networkmanager's own part: the watcher's subcommand (design 08 sign-in-page §11).
func TestNetworkManagerRunsItsWatcherAsASubcommand(t *testing.T) {
if run, err := command(holder(Machine{}), []string{"watch"}); err != nil || run == nil {
t.Fatalf("uplink-tools watch is not the watcher: %v", err)
}
}