MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestCreateBindStr

Function TestCreateBindStr

cmd/tailscale/cli/netcheck_test.go:10–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestCreateBindStr(t *testing.T) {
11 // Test all combinations of CLI arg address, CLI arg port, and env var string
12 // as inputs to create netcheck bind string.
13 tests := []struct {
14 name string
15 cliAddress string
16 cliAddressIsSet bool
17 cliPort int
18 cliPortIsSet bool
19 envBind string
20 want string
21 wantError string
22 }{
23 {
24 name: "noAddr-noPort-noEnv",
25 want: ":0",
26 },
27 {
28 name: "yesAddrv4-noPort-noEnv",
29 cliAddress: "100.123.123.123",
30 cliAddressIsSet: true,
31 want: "100.123.123.123:0",
32 },
33 {
34 name: "yesAddrv6-noPort-noEnv",
35 cliAddress: "dead::beef",
36 cliAddressIsSet: true,
37 want: "[dead::beef]:0",
38 },
39 {
40 name: "yesAddr-yesPort-noEnv",
41 cliAddress: "100.123.123.123",
42 cliAddressIsSet: true,
43 cliPort: 456,
44 cliPortIsSet: true,
45 want: "100.123.123.123:456",
46 },
47 {
48 name: "yesAddr-yesPort-yesEnv",
49 cliAddress: "100.123.123.123",
50 cliAddressIsSet: true,
51 cliPort: 456,
52 cliPortIsSet: true,
53 envBind: "55.55.55.55:789",
54 want: "100.123.123.123:456",
55 },
56 {
57 name: "noAddr-yesPort-noEnv",
58 cliPort: 456,
59 cliPortIsSet: true,
60 want: ":456",
61 },
62 {
63 name: "noAddr-yesPort-yesEnv",
64 cliPort: 456,
65 cliPortIsSet: true,
66 envBind: "55.55.55.55:789",
67 want: ":456",

Callers

nothing calls this directly

Calls 4

createNetcheckBindStringFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…