package profile import ( "context" "errors" "testing" ) // The uplink seat's holder must be the dialect the machine runs (novox/hq ADR 0161): the profile // names the network manager found active, one capability per manager, and nothing for one that is // merely installed. func TestTheProfileNamesTheNetworkManagerThatIsRunning(t *testing.T) { runner := func(_ context.Context, name string, args ...string) (string, error) { if name == "systemctl" && len(args) == 2 && args[0] == "is-active" { if args[1] == "NetworkManager.service" { return "active\n", nil } return "inactive\n", errors.New("exit status 3") } return "", errors.New("not here") } var have []Detector for _, d := range Default(Runner(runner)) { switch d.Name() { case CapUplinkNetworkManager, CapUplinkSystemdNetworkd, CapUplinkDhcpcd: have = append(have, d) } } if len(have) != 3 { t.Fatalf("expected a detector per manager, found %d", len(have)) } for _, d := range have { v := d.Detect(context.Background()) want := d.Name() == CapUplinkNetworkManager if v.Present != want { t.Errorf("%s: present=%v, want %v (%s)", d.Name(), v.Present, want, v.Detail) } } }