summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/modifiers_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4/modifiers_test.go')
-rw-r--r--dhcpv4/modifiers_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/dhcpv4/modifiers_test.go b/dhcpv4/modifiers_test.go
index 2f0e1ed..c40088c 100644
--- a/dhcpv4/modifiers_test.go
+++ b/dhcpv4/modifiers_test.go
@@ -67,3 +67,22 @@ func TestWithNetbootExistingBoth(t *testing.T) {
d = WithNetboot(d)
require.Equal(t, "Parameter Request List -> [Bootfile Name, TFTP Server Name]", d.options[0].String())
}
+
+func TestWithRequestedOptions(t *testing.T) {
+ // Check if OptionParameterRequestList is created when not present
+ d, err := New()
+ require.NoError(t, err)
+ d = WithRequestedOptions(OptionFQDN)(d)
+ require.NotNil(t, d)
+ o := d.GetOneOption(OptionParameterRequestList)
+ require.NotNil(t, o)
+ opts := o.(*OptParameterRequestList)
+ require.ElementsMatch(t, opts.RequestedOpts, []OptionCode{OptionFQDN})
+ // Check if already set options are preserved
+ d = WithRequestedOptions(OptionHostName)(d)
+ require.NotNil(t, d)
+ o = d.GetOneOption(OptionParameterRequestList)
+ require.NotNil(t, o)
+ opts = o.(*OptParameterRequestList)
+ require.ElementsMatch(t, opts.RequestedOpts, []OptionCode{OptionFQDN, OptionHostName})
+}