You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/net/dns/config_test.go

67 lines
1.3 KiB
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
package dns
import (
"net/netip"
"reflect"
"testing"
"tailscale.com/types/dnstype"
"tailscale.com/util/dnsname"
)
func TestConfigClone(t *testing.T) {
tests := []struct {
name string
conf *Config
}{
{
name: "nil",
conf: nil,
},
{
name: "empty",
conf: &Config{},
},
{
name: "full",
conf: &Config{
DefaultResolvers: []*dnstype.Resolver{
{
Addr: "abc",
BootstrapResolution: []netip.Addr{netip.MustParseAddr("1.2.3.4")},
UseWithExitNode: true,
},
},
Routes: map[dnsname.FQDN][]*dnstype.Resolver{
"foo.bar.": {
{
Addr: "abc",
BootstrapResolution: []netip.Addr{netip.MustParseAddr("1.2.3.4")},
UseWithExitNode: true,
},
},
},
SearchDomains: []dnsname.FQDN{"bar.baz."},
Hosts: map[dnsname.FQDN][]netip.Addr{
"host.bar.": {netip.MustParseAddr("5.6.7.8")},
},
OnlyIPv6: true,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.conf.Clone()
if !reflect.DeepEqual(got, tt.conf) {
t.Error("Cloned result is not reflect.DeepEqual")
}
if !got.Equal(tt.conf) {
t.Error("Cloned result is not Equal")
}
})
}
}