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

Function TestPeerChangeDiff

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

Source from the content-addressed store, hash-verified

1149}
1150
1151func TestPeerChangeDiff(t *testing.T) {
1152 tests := []struct {
1153 name string
1154 a, b *tailcfg.Node
1155 want *tailcfg.PeerChange // nil means want ok=false, unless wantEqual is set
1156 wantEqual bool // means test wants (nil, true)
1157 }{
1158 {
1159 name: "eq",
1160 a: &tailcfg.Node{ID: 1},
1161 b: &tailcfg.Node{ID: 1},
1162 wantEqual: true,
1163 },
1164 {
1165 name: "patch-derp",
1166 a: &tailcfg.Node{ID: 1, HomeDERP: 1},
1167 b: &tailcfg.Node{ID: 1, HomeDERP: 2},
1168 want: &tailcfg.PeerChange{NodeID: 1, DERPRegion: 2},
1169 },
1170 {
1171 name: "patch-endpoints",
1172 a: &tailcfg.Node{ID: 1, Endpoints: eps("10.0.0.1:1")},
1173 b: &tailcfg.Node{ID: 1, Endpoints: eps("10.0.0.2:2")},
1174 want: &tailcfg.PeerChange{NodeID: 1, Endpoints: eps("10.0.0.2:2")},
1175 },
1176 {
1177 name: "patch-cap",
1178 a: &tailcfg.Node{ID: 1, Cap: 1},
1179 b: &tailcfg.Node{ID: 1, Cap: 2},
1180 want: &tailcfg.PeerChange{NodeID: 1, Cap: 2},
1181 },
1182 {
1183 name: "patch-lastseen",
1184 a: &tailcfg.Node{ID: 1, LastSeen: new(time.Unix(1, 0))},
1185 b: &tailcfg.Node{ID: 1, LastSeen: new(time.Unix(2, 0))},
1186 want: &tailcfg.PeerChange{NodeID: 1, LastSeen: new(time.Unix(2, 0))},
1187 },
1188 {
1189 name: "patch-online-to-true",
1190 a: &tailcfg.Node{ID: 1, Online: new(false)},
1191 b: &tailcfg.Node{ID: 1, Online: new(true)},
1192 want: &tailcfg.PeerChange{NodeID: 1, Online: new(true)},
1193 },
1194 {
1195 name: "patch-online-to-false",
1196 a: &tailcfg.Node{ID: 1, Online: new(true)},
1197 b: &tailcfg.Node{ID: 1, Online: new(false)},
1198 want: &tailcfg.PeerChange{NodeID: 1, Online: new(false)},
1199 },
1200 {
1201 name: "mix-patchable-and-not",
1202 a: &tailcfg.Node{ID: 1, Cap: 1},
1203 b: &tailcfg.Node{ID: 1, Cap: 2, StableID: "foo"},
1204 want: nil,
1205 },
1206 {
1207 name: "miss-change-stableid",
1208 a: &tailcfg.Node{ID: 1},

Callers

nothing calls this directly

Calls 7

AsJSONFunction · 0.92
peerChangeDiffFunction · 0.85
epsFunction · 0.70
RunMethod · 0.65
ViewMethod · 0.65
ErrorfMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…