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/control/controlclient/netmap_test.go

37 lines
1015 B
Go

// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package controlclient
import (
"testing"
"tailscale.com/tailcfg"
)
func TestNetworkMapConcise(t *testing.T) {
nm := &NetworkMap{
Peers: []*tailcfg.Node{
{
Name: "foo",
Endpoints: []string{"192.168.0.100:12", "192.168.0.100:12354"},
},
{
Name: "bar",
Endpoints: []string{"10.2.0.100:12", "10.1.0.100:12345"},
},
},
}
var got string
n := int(testing.AllocsPerRun(1000, func() {
got = nm.Concise()
}))
t.Logf("Allocs = %d", n)
want := "netmap: self: [AAAAA] auth=machine-unknown :0 []\n" +
" [AAAAA] : 192.168.0.100:12 192.168.0.100:12354\n [AAAAA] : 10.2.0.100:12 10.1.0.100:12345\n"
if got != want {
t.Errorf("Wrong output\n Got: %q\nWant: %q\n## Got (unescaped):\n%s\n## Want (unescaped):\n%s\n", got, want, got, want)
}
}