From fd26ffdbe087ea69ccce6b043c1aedfc72a1c4dc Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Sat, 1 Oct 2022 14:56:15 +0300 Subject: dhcpv4: add test for NewInform() with modifiers `NewInform()` exposes a consumer-facing interface that accepts modifiers, but this functionality is never tested unlike with for example `NewRequest()` and `NewRenew()`. To ensure that modifiers are correctly respected and any future modifications won't break this support, add a modifier test for `NewInform()`. Signed-off-by: Dennis Marttinen --- dhcpv4/dhcpv4_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dhcpv4/dhcpv4_test.go b/dhcpv4/dhcpv4_test.go index eff7a71..d2d6edd 100644 --- a/dhcpv4/dhcpv4_test.go +++ b/dhcpv4/dhcpv4_test.go @@ -355,6 +355,16 @@ func TestNewInform(t *testing.T) { require.True(t, m.ClientIPAddr.Equal(localIP)) } +func TestDHCPv4NewInformWithModifier(t *testing.T) { + hwAddr := net.HardwareAddr{1, 2, 3, 4, 5, 6} + localIP := net.IPv4(10, 10, 11, 11) + serverID := net.IPv4(192, 168, 0, 1) + m, err := NewInform(hwAddr, localIP, WithOption(OptServerIdentifier(serverID))) + + require.NoError(t, err) + require.True(t, serverID.Equal(m.ServerIdentifier())) +} + func TestIsOptionRequested(t *testing.T) { pkt, err := New() require.NoError(t, err) -- cgit v1.2.3