master
go 37 lines 815 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package l2topology
4
5 import (
6 "testing"
7
8 "github.com/stretchr/testify/require"
9 )
10
11 func TestBridgeAttachmentSortKey_DistinguishesVLANAndMethod(t *testing.T) {
12 base := Attachment{
13 DeviceID: "switch-a",
14 IfIndex: 7,
15 EndpointID: "mac:00:11:22:33:44:55",
16 Labels: map[string]string{
17 "if_name": "swp07",
18 "bridge_port": "7",
19 "vlan_id": "20",
20 },
21 }
22
23 fdb := base
24 fdb.Method = "fdb"
25 arp := base
26 arp.Method = "arp"
27 otherVLAN := base
28 otherVLAN.Method = "fdb"
29 otherVLAN.Labels = map[string]string{
30 "if_name": "swp07",
31 "bridge_port": "7",
32 "vlan_id": "30",
33 }
34
35 require.NotEqual(t, bridgeAttachmentSortKey(fdb), bridgeAttachmentSortKey(arp))
36 require.NotEqual(t, bridgeAttachmentSortKey(fdb), bridgeAttachmentSortKey(otherVLAN))
37 }