diff options
Diffstat (limited to 'dhcpv6/modifiers_test.go')
-rw-r--r-- | dhcpv6/modifiers_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/dhcpv6/modifiers_test.go b/dhcpv6/modifiers_test.go index ab21367..9953f8b 100644 --- a/dhcpv6/modifiers_test.go +++ b/dhcpv6/modifiers_test.go @@ -35,3 +35,19 @@ func TestWithServerID(t *testing.T) { sid := opt.(*OptServerId) require.Equal(t, sid.Sid, duid) } + +func TestWithRequestedOptions(t *testing.T) { + // Check if ORO is created when no ORO present + m, err := NewMessage(WithRequestedOptions(OptionClientID)) + require.NoError(t, err) + opt := m.GetOneOption(OptionORO) + require.NotNil(t, opt) + oro := opt.(*OptRequestedOption) + require.ElementsMatch(t, oro.RequestedOptions(), []OptionCode{OptionClientID}) + // Check if already set options are preserved + m = WithRequestedOptions(OptionServerID)(m) + opt = m.GetOneOption(OptionORO) + require.NotNil(t, opt) + oro = opt.(*OptRequestedOption) + require.ElementsMatch(t, oro.RequestedOptions(), []OptionCode{OptionClientID, OptionServerID}) +} |