mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-24 10:10:59 +00:00
Add names to test cases in ipn/local_test.go.
There are so many now that just a number doesn't work well. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:
parent
67ebc7c0e7
commit
fa3e8e1a28
@ -25,81 +25,95 @@ func TestNetworkMapCompare(t *testing.T) {
|
|||||||
node2 := &tailcfg.Node{Addresses: []netaddr.IPPrefix{prefix2}}
|
node2 := &tailcfg.Node{Addresses: []netaddr.IPPrefix{prefix2}}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
name string
|
||||||
a, b *controlclient.NetworkMap
|
a, b *controlclient.NetworkMap
|
||||||
want bool
|
want bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
"both nil",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"b nil",
|
||||||
&controlclient.NetworkMap{},
|
&controlclient.NetworkMap{},
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"a nil",
|
||||||
nil,
|
nil,
|
||||||
&controlclient.NetworkMap{},
|
&controlclient.NetworkMap{},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"both default",
|
||||||
&controlclient.NetworkMap{},
|
&controlclient.NetworkMap{},
|
||||||
&controlclient.NetworkMap{},
|
&controlclient.NetworkMap{},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"names identical",
|
||||||
&controlclient.NetworkMap{Name: "map1"},
|
&controlclient.NetworkMap{Name: "map1"},
|
||||||
&controlclient.NetworkMap{Name: "map1"},
|
&controlclient.NetworkMap{Name: "map1"},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"names differ",
|
||||||
&controlclient.NetworkMap{Name: "map1"},
|
&controlclient.NetworkMap{Name: "map1"},
|
||||||
&controlclient.NetworkMap{Name: "map2"},
|
&controlclient.NetworkMap{Name: "map2"},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Peers identical",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Peer list length",
|
||||||
// length of Peers list differs
|
// length of Peers list differs
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{{}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{{}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Node names identical",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Node names differ",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "A"}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "B"}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{Name: "B"}}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Node lists identical",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Node lists differ",
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node1}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node2}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{node1, node2}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"Node Users differ",
|
||||||
// User field is not checked.
|
// User field is not checked.
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 0}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 0}}},
|
||||||
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 1}}},
|
&controlclient.NetworkMap{Peers: []*tailcfg.Node{&tailcfg.Node{User: 1}}},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, tt := range tests {
|
for _, tt := range tests {
|
||||||
got := dnsMapsEqual(tt.a, tt.b)
|
got := dnsMapsEqual(tt.a, tt.b)
|
||||||
if got != tt.want {
|
if got != tt.want {
|
||||||
t.Errorf("%d. Equal = %v; want %v", i, got, tt.want)
|
t.Errorf("%s: Equal = %v; want %v", tt.name, got, tt.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user