MCPcopy
hub / github.com/tailscale/tailscale / TestUpgradeNode

Function TestUpgradeNode

control/controlclient/map_test.go:1481–1557  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1479}
1480
1481func TestUpgradeNode(t *testing.T) {
1482 a1 := netip.MustParsePrefix("0.0.0.1/32")
1483 a2 := netip.MustParsePrefix("0.0.0.2/32")
1484 a3 := netip.MustParsePrefix("0.0.0.3/32")
1485 a4 := netip.MustParsePrefix("0.0.0.4/32")
1486
1487 tests := []struct {
1488 name string
1489 in *tailcfg.Node
1490 want *tailcfg.Node
1491 also func(t *testing.T, got *tailcfg.Node) // optional
1492 }{
1493 {
1494 name: "nil",
1495 in: nil,
1496 want: nil,
1497 },
1498 {
1499 name: "empty",
1500 in: new(tailcfg.Node),
1501 want: new(tailcfg.Node),
1502 },
1503 {
1504 name: "derp-both",
1505 in: &tailcfg.Node{HomeDERP: 1, LegacyDERPString: tailcfg.DerpMagicIP + ":2"},
1506 want: &tailcfg.Node{HomeDERP: 1},
1507 },
1508 {
1509 name: "derp-str-only",
1510 in: &tailcfg.Node{LegacyDERPString: tailcfg.DerpMagicIP + ":2"},
1511 want: &tailcfg.Node{HomeDERP: 2},
1512 },
1513 {
1514 name: "derp-int-only",
1515 in: &tailcfg.Node{HomeDERP: 2},
1516 want: &tailcfg.Node{HomeDERP: 2},
1517 },
1518 {
1519 name: "implicit-allowed-ips-all-set",
1520 in: &tailcfg.Node{Addresses: []netip.Prefix{a1, a2}, AllowedIPs: []netip.Prefix{a3, a4}},
1521 want: &tailcfg.Node{Addresses: []netip.Prefix{a1, a2}, AllowedIPs: []netip.Prefix{a3, a4}},
1522 },
1523 {
1524 name: "implicit-allowed-ips-only-address-set",
1525 in: &tailcfg.Node{Addresses: []netip.Prefix{a1, a2}},
1526 want: &tailcfg.Node{Addresses: []netip.Prefix{a1, a2}, AllowedIPs: []netip.Prefix{a1, a2}},
1527 also: func(t *testing.T, got *tailcfg.Node) {
1528 if t.Failed() {
1529 return
1530 }
1531 if &got.Addresses[0] == &got.AllowedIPs[0] {
1532 t.Error("Addresses and AllowIPs alias the same memory")
1533 }
1534 },
1535 },
1536 {
1537 name: "implicit-allowed-ips-set-empty-slice",
1538 in: &tailcfg.Node{Addresses: []netip.Prefix{a1, a2}, AllowedIPs: []netip.Prefix{}},

Callers

nothing calls this directly

Calls 6

upgradeNodeFunction · 0.85
DiffMethod · 0.80
FailedMethod · 0.65
ErrorMethod · 0.65
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…