Skip to content

Commit

Permalink
client: imp naming
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Apr 24, 2024
1 parent 922a14b commit 58d2fd9
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions internal/client/index_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,42 @@ func TestClientIndex(t *testing.T) {
)

var (
ClientOne = &Persistent{
clientWithBothFams = &Persistent{
Name: "client1",
IPs: []netip.Addr{
netip.MustParseAddr(cliIP1),
netip.MustParseAddr(cliIPv6),
},
}

ClientTwo = &Persistent{
clientWithSubnet = &Persistent{
Name: "client2",
IPs: []netip.Addr{netip.MustParseAddr(cliIP2)},
Subnets: []netip.Prefix{netip.MustParsePrefix(cliSubnet)},
}

ClientWithMAC = &Persistent{
clientWithMAC = &Persistent{
Name: "client_with_mac",
MACs: []net.HardwareAddr{mustParseMAC(cliMAC)},
}

ClientWithID = &Persistent{
clientWithID = &Persistent{
Name: "client_with_id",
ClientIDs: []string{cliID},
}

ClientLinkLocal = &Persistent{
clientLinkLocal = &Persistent{
Name: "client_link_local",
Subnets: []netip.Prefix{netip.MustParsePrefix(linkLocalSubnet)},
}
)

ci := newIDIndex([]*Persistent{
ClientOne,
ClientTwo,
ClientWithMAC,
ClientWithID,
ClientLinkLocal,
clientWithBothFams,
clientWithSubnet,
clientWithMAC,
clientWithID,
clientLinkLocal,
})

testCases := []struct {
Expand All @@ -86,23 +86,23 @@ func TestClientIndex(t *testing.T) {
}{{
name: "ipv4_ipv6",
ids: []string{cliIP1, cliIPv6},
want: ClientOne,
want: clientWithBothFams,
}, {
name: "ipv4_subnet",
ids: []string{cliIP2, cliSubnetIP},
want: ClientTwo,
want: clientWithSubnet,
}, {
name: "mac",
ids: []string{cliMAC},
want: ClientWithMAC,
want: clientWithMAC,
}, {
name: "client_id",
ids: []string{cliID},
want: ClientWithID,
want: clientWithID,
}, {
name: "client_link_local_subnet",
ids: []string{linkLocalIP},
want: ClientLinkLocal,
want: clientLinkLocal,
}}

for _, tc := range testCases {
Expand Down Expand Up @@ -255,20 +255,20 @@ func TestIndex_FindByIPWithoutZone(t *testing.T) {
)

var (
Client = &Persistent{
clientNoZone = &Persistent{
Name: "client",
IPs: []netip.Addr{ip},
}

ClientWithZone = &Persistent{
clientWithZone = &Persistent{
Name: "client_with_zone",
IPs: []netip.Addr{ipWithZone},
}
)

ci := newIDIndex([]*Persistent{
Client,
ClientWithZone,
clientNoZone,
clientWithZone,
})

testCases := []struct {
Expand All @@ -278,11 +278,11 @@ func TestIndex_FindByIPWithoutZone(t *testing.T) {
}{{
name: "without_zone",
ip: ip,
want: Client,
want: clientNoZone,
}, {
name: "with_zone",
ip: ipWithZone,
want: ClientWithZone,
want: clientWithZone,
}, {
name: "zero_address",
ip: netip.Addr{},
Expand Down

0 comments on commit 58d2fd9

Please sign in to comment.