diff options
author | MikoĊaj Walczak <mikiwalczak+github@gmail.com> | 2018-08-22 14:56:53 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-08-22 14:56:53 +0100 |
commit | 051f4413e8ae8c174024f754d7b21ec13a5460b9 (patch) | |
tree | 7567bcfb808f1018a2fba490818f08921bc83546 /dhcpv4/modifiers_test.go | |
parent | b54e51afcac769dfd51a0df3ec5f73fc390de1a3 (diff) |
Requested Options modifier for DHCPv4 (#147)
Diffstat (limited to 'dhcpv4/modifiers_test.go')
-rw-r--r-- | dhcpv4/modifiers_test.go | 19 |
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}) +} |