summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_requestedoption_test.go
diff options
context:
space:
mode:
authorDavid Barr <38654497+davebarrau@users.noreply.github.com>2018-10-12 11:09:04 +1100
committerinsomniac <insomniacslk@users.noreply.github.com>2018-10-11 17:09:04 -0700
commitdc01165c86340093eacf62c0856ae4e2164a4845 (patch)
tree9ca76ae4103c3e63cd86620fdec230e5cfe5b78d /dhcpv6/option_requestedoption_test.go
parentee671d361777cc640550bab38cc6b0d412396f80 (diff)
Add some more DHCPv6 option tests. (#171)
* Add some more DHCPv6 option tests. * Remove AddRequestedOption() duplicate detection test due to failing on Go 1.9
Diffstat (limited to 'dhcpv6/option_requestedoption_test.go')
-rw-r--r--dhcpv6/option_requestedoption_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/dhcpv6/option_requestedoption_test.go b/dhcpv6/option_requestedoption_test.go
new file mode 100644
index 0000000..7e95e36
--- /dev/null
+++ b/dhcpv6/option_requestedoption_test.go
@@ -0,0 +1,38 @@
+package dhcpv6
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestOptRequestedOption(t *testing.T) {
+ expected := []byte{0, 1, 0, 2}
+ _, err := ParseOptRequestedOption(expected)
+ require.NoError(t, err, "ParseOptRequestedOption() correct options should not error")
+}
+
+func TestOptRequestedOptionParseOptRequestedOptionTooShort(t *testing.T) {
+ buf := []byte{0, 1, 0}
+ _, err := ParseOptRequestedOption(buf)
+ require.Error(t, err, "A short option should return an error (must be divisible by 2)")
+}
+
+func TestOptRequestedOptionString(t *testing.T) {
+ buf := []byte{0, 1, 0, 2}
+ opt, err := ParseOptRequestedOption(buf)
+ require.NoError(t, err)
+ require.Contains(
+ t,
+ opt.String(),
+ "OPTION_CLIENTID, OPTION_SERVERID",
+ "String() should contain the options specified",
+ )
+ opt.AddRequestedOption(12345)
+ require.Contains(
+ t,
+ opt.String(),
+ "Unknown",
+ "String() should contain 'Unknown' for an illegal option",
+ )
+}