summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_nontemporaryaddress_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6/option_nontemporaryaddress_test.go')
-rw-r--r--dhcpv6/option_nontemporaryaddress_test.go50
1 files changed, 28 insertions, 22 deletions
diff --git a/dhcpv6/option_nontemporaryaddress_test.go b/dhcpv6/option_nontemporaryaddress_test.go
index ceee9ec..50cb11b 100644
--- a/dhcpv6/option_nontemporaryaddress_test.go
+++ b/dhcpv6/option_nontemporaryaddress_test.go
@@ -46,16 +46,16 @@ func TestOptIANAGetOneOption(t *testing.T) {
IPv6Addr: net.ParseIP("::1"),
}
opt := OptIANA{
- Options: []Option{OptElapsedTime(0), oaddr},
+ Options: IdentityOptions{[]Option{&OptStatusCode{}, oaddr}},
}
- require.Equal(t, oaddr, opt.GetOneOption(OptionIAAddr))
+ require.Equal(t, oaddr, opt.Options.OneAddress())
}
func TestOptIANAAddOption(t *testing.T) {
opt := OptIANA{}
- opt.AddOption(OptElapsedTime(0))
- require.Equal(t, 1, len(opt.Options))
- require.Equal(t, OptionElapsedTime, opt.Options[0].Code())
+ opt.Options.Add(OptElapsedTime(0))
+ require.Equal(t, 1, len(opt.Options.Options))
+ require.Equal(t, OptionElapsedTime, opt.Options.Options[0].Code())
}
func TestOptIANAGetOneOptionMissingOpt(t *testing.T) {
@@ -63,28 +63,34 @@ func TestOptIANAGetOneOptionMissingOpt(t *testing.T) {
IPv6Addr: net.ParseIP("::1"),
}
opt := OptIANA{
- Options: []Option{OptElapsedTime(0), oaddr},
+ Options: IdentityOptions{[]Option{&OptStatusCode{}, oaddr}},
}
- require.Equal(t, nil, opt.GetOneOption(OptionDNSRecursiveNameServer))
+ require.Equal(t, nil, opt.Options.GetOne(OptionDNSRecursiveNameServer))
}
func TestOptIANADelOption(t *testing.T) {
- optiana1 := OptIANA{}
- optiana2 := OptIANA{}
optiaaddr := OptIAAddress{}
optsc := OptStatusCode{}
- optiana1.Options = append(optiana1.Options, &optsc)
- optiana1.Options = append(optiana1.Options, &optiaaddr)
- optiana1.Options = append(optiana1.Options, &optiaaddr)
- optiana1.DelOption(OptionIAAddr)
- require.Equal(t, optiana1.Options, Options{&optsc})
+ iana1 := OptIANA{
+ Options: IdentityOptions{[]Option{
+ &optsc,
+ &optiaaddr,
+ &optiaaddr,
+ }},
+ }
+ iana1.Options.Del(OptionIAAddr)
+ require.Equal(t, iana1.Options.Options, Options{&optsc})
- optiana2.Options = append(optiana2.Options, &optiaaddr)
- optiana2.Options = append(optiana2.Options, &optsc)
- optiana2.Options = append(optiana2.Options, &optiaaddr)
- optiana2.DelOption(OptionIAAddr)
- require.Equal(t, optiana2.Options, Options{&optsc})
+ iana2 := OptIANA{
+ Options: IdentityOptions{[]Option{
+ &optiaaddr,
+ &optsc,
+ &optiaaddr,
+ }},
+ }
+ iana2.Options.Del(OptionIAAddr)
+ require.Equal(t, iana2.Options.Options, Options{&optsc})
}
func TestOptIANAToBytes(t *testing.T) {
@@ -92,9 +98,9 @@ func TestOptIANAToBytes(t *testing.T) {
IaId: [4]byte{1, 2, 3, 4},
T1: 12345 * time.Second,
T2: 54321 * time.Second,
- Options: []Option{
+ Options: IdentityOptions{[]Option{
OptElapsedTime(10 * time.Millisecond),
- },
+ }},
}
expected := []byte{
1, 2, 3, 4, // IA ID
@@ -128,7 +134,7 @@ func TestOptIANAString(t *testing.T) {
)
require.Contains(
t, str,
- "options=[",
+ "options={",
"String() should return a list of options",
)
}