net/dns: fix IsZero and Equal methods on OSConfig
Discovered this while investigating the following issue; I think it's unrelated, but might as well fix it. Also, add a test helper for checking things that have an IsZero method using the reflect package. Updates tailscale/support-escalations#55 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I57b7adde43bcef9483763b561da173b4c35f49e2
This commit is contained in:
@ -6,8 +6,10 @@ package dns
|
||||
import (
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/util/dnsname"
|
||||
)
|
||||
|
||||
@ -41,3 +43,13 @@ func TestOSConfigPrintable(t *testing.T) {
|
||||
t.Errorf("format mismatch:\n got: %s\n want: %s", s, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsZero(t *testing.T) {
|
||||
tstest.CheckIsZero[OSConfig](t, map[reflect.Type]any{
|
||||
reflect.TypeFor[dnsname.FQDN](): dnsname.FQDN("foo.bar."),
|
||||
reflect.TypeFor[*HostEntry](): &HostEntry{
|
||||
Addr: netip.AddrFrom4([4]byte{100, 1, 2, 3}),
|
||||
Hosts: []string{"foo", "bar"},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user