(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func TestNetworkMapConcise(t *testing.T) { |
| 56 | for _, tt := range []struct { |
| 57 | name string |
| 58 | nm *NetworkMap |
| 59 | want string |
| 60 | }{ |
| 61 | { |
| 62 | name: "basic", |
| 63 | nm: &NetworkMap{ |
| 64 | NodeKey: testNodeKey(1), |
| 65 | Peers: nodeViews([]*tailcfg.Node{ |
| 66 | { |
| 67 | Key: testNodeKey(2), |
| 68 | HomeDERP: 2, |
| 69 | Endpoints: eps("192.168.0.100:12", "192.168.0.100:12354"), |
| 70 | }, |
| 71 | { |
| 72 | Key: testNodeKey(3), |
| 73 | HomeDERP: 4, |
| 74 | Endpoints: eps("10.2.0.100:12", "10.1.0.100:12345"), |
| 75 | }, |
| 76 | }), |
| 77 | }, |
| 78 | want: "netmap: self: [AQEBA] auth=machine-unknown u=? []\n [AgICA] D2 : 192.168.0.100:12 192.168.0.100:12354\n [AwMDA] D4 : 10.2.0.100:12 10.1.0.100:12345\n", |
| 79 | }, |
| 80 | } { |
| 81 | t.Run(tt.name, func(t *testing.T) { |
| 82 | var got string |
| 83 | n := int(testing.AllocsPerRun(1000, func() { |
| 84 | got = tt.nm.Concise() |
| 85 | })) |
| 86 | t.Logf("Allocs = %d", n) |
| 87 | if got != tt.want { |
| 88 | t.Errorf("Wrong output\n Got: %q\nWant: %q\n## Got (unescaped):\n%s\n## Want (unescaped):\n%s\n", got, tt.want, got, tt.want) |
| 89 | } |
| 90 | }) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func TestConciseDiffFrom(t *testing.T) { |
| 95 | for _, tt := range []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…