mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-28 14:51:32 +01:00
I got sidetracked apparently and never finished writing this Clone code in 316afe7d02babc (#17448). (It really should use views instead.) And then I missed one of the users of "routerChanged" that was broken up into "routerChanged" vs "dnsChanged". This broke integration tests elsewhere. Fixes #17506 Change-Id: I533bf0fcf3da9ac6eb4a6cdef03b8df2c1fb4c8e Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
67 lines
1.3 KiB
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")
|
|
}
|
|
})
|
|
}
|
|
}
|