(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestAddRemoveEndpoint(t *testing.T) { |
| 17 | logger := hivetest.Logger(t) |
| 18 | ifaces, err := safenetlink.LinkList() |
| 19 | require.NoError(t, err) |
| 20 | |
| 21 | if len(ifaces) == 0 { |
| 22 | t.Skip("no interfaces to test") |
| 23 | } |
| 24 | |
| 25 | mgr := New(logger, ifaces[0].Attrs().Name) |
| 26 | |
| 27 | // Add first endpoint |
| 28 | mgr.AddAddress(netip.MustParseAddr("f00d::1234")) |
| 29 | |
| 30 | require.Len(t, mgr.state, 1) |
| 31 | _, ok := mgr.state[netip.MustParseAddr("ff02::1:ff00:1234")] |
| 32 | require.True(t, ok) |
| 33 | |
| 34 | // Add another endpoint that shares the same maddr |
| 35 | mgr.AddAddress(netip.MustParseAddr("f00d:aabb::1234")) |
| 36 | |
| 37 | require.Len(t, mgr.state, 1) |
| 38 | |
| 39 | // Remove the first endpoint |
| 40 | mgr.RemoveAddress(netip.MustParseAddr("f00d::1234")) |
| 41 | |
| 42 | require.Len(t, mgr.state, 1) |
| 43 | _, ok = mgr.state[netip.MustParseAddr("ff02::1:ff00:1234")] |
| 44 | require.True(t, ok) |
| 45 | |
| 46 | // Remove the second endpoint |
| 47 | mgr.RemoveAddress(netip.MustParseAddr("f00d:aabb::1234")) |
| 48 | |
| 49 | require.Empty(t, mgr.state) |
| 50 | _, ok = mgr.state[netip.MustParseAddr("ff02::1:ff00:1234")] |
| 51 | require.False(t, ok) |
| 52 | } |
| 53 | |
| 54 | func TestAddRemoveNil(t *testing.T) { |
| 55 | logger := hivetest.Logger(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…