package main import "testing" func TestMDNSEnvironmentSwitches(t *testing.T) { for value, want := range map[string]bool{"": true, "1": true, "on": true, "off": false, "0": false, "FALSE": false, " disabled ": false} { if got := envEnabled(value); got != want { t.Errorf("envEnabled(%q) = %v, want %v", value, got, want) } } for value, want := range map[string]int{"": 0, "8083": 8083, "x": 0, "70000": 0} { if got := envPort(value); got != want { t.Errorf("envPort(%q) = %d, want %d", value, got, want) } } } // A loopback-only server with no proxy port publishes nothing and does not // fail: the caller only defers a non-nil stop. func TestAdvertiseSkipsLoopbackWithoutFailing(t *testing.T) { if stop := advertise("127.0.0.1:0", 0); stop != nil { stop() t.Fatal("loopback-only server was advertised") } }