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) } }