package main import ( "testing" "github.com/novox/mesh-host/internal/link" "github.com/novox/mesh-host/internal/outward" "github.com/novox/mesh-host/internal/profile" ) func reportOn(networks ...outward.Network) link.Report { return link.Report{Outward: []string{"eth0"}, Profile: profileAsReported(profile.Profile{Machine: &profile.Machine{Networks: networks}})} } // **A change of the networks a machine is attached to is said unasked** (novox/hq ADR 0340 §7): a port // reached from the local network is admitted from them, so a laptop that joins another network is said at // the next reconcile, not at the next push — and the same networks again are not news. func TestAChangedNetworkIsSaidUnasked(t *testing.T) { w := &adoptionWatch{} home := reportOn(outward.Network{Link: "eth0", Network: "192.168.1.0/24"}) w.said(home) if w.differs(reportOn(outward.Network{Link: "eth0", Network: "192.168.1.0/24"})) { t.Fatal("the same networks read as a change, so the machine would speak on every reconcile") } if !w.differs(reportOn(outward.Network{Link: "eth0", Network: "10.20.0.0/16"})) { t.Fatal("a machine that moved to another network does not say so until it is pushed to") } }