summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_domain_name_server_test.go
diff options
context:
space:
mode:
authorChristopher Koch <chrisko@google.com>2018-12-29 09:21:33 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-14 23:19:04 +0000
commit158ad8e79b2e644da7dfbfceb9191e6587ede81e (patch)
tree3618cbf06e7e34d835495047ec634b5b93824432 /dhcpv4/option_domain_name_server_test.go
parent03a987ca7475df51eb9164e807f9c1929017e08a (diff)
dhcpv4: move all list of IPs types to options_ips.go.
Diffstat (limited to 'dhcpv4/option_domain_name_server_test.go')
-rw-r--r--dhcpv4/option_domain_name_server_test.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/dhcpv4/option_domain_name_server_test.go b/dhcpv4/option_domain_name_server_test.go
deleted file mode 100644
index 407e0d6..0000000
--- a/dhcpv4/option_domain_name_server_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package dhcpv4
-
-import (
- "net"
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
-func TestOptDomainNameServerInterfaceMethods(t *testing.T) {
- servers := []net.IP{
- net.IPv4(192, 168, 0, 10),
- net.IPv4(192, 168, 0, 20),
- }
- o := OptDomainNameServer{NameServers: servers}
- require.Equal(t, OptionDomainNameServer, o.Code(), "Code")
- require.Equal(t, servers, o.NameServers, "NameServers")
-}
-
-func TestParseOptDomainNameServer(t *testing.T) {
- data := []byte{
- byte(OptionDomainNameServer),
- 8, // Length
- 192, 168, 0, 10, // DNS #1
- 192, 168, 0, 20, // DNS #2
- }
- o, err := ParseOptDomainNameServer(data[2:])
- require.NoError(t, err)
- servers := []net.IP{
- net.IP{192, 168, 0, 10},
- net.IP{192, 168, 0, 20},
- }
- require.Equal(t, &OptDomainNameServer{NameServers: servers}, o)
-
- // Bad length
- data = []byte{1, 1, 1}
- _, err = ParseOptDomainNameServer(data)
- require.Error(t, err, "should get error from bad length")
-}
-
-func TestParseOptDomainNameServerNoServers(t *testing.T) {
- // RFC2132 requires that at least one DNS server IP is specified
- _, err := ParseOptDomainNameServer([]byte{})
- require.Error(t, err)
-}
-
-func TestOptDomainNameServerString(t *testing.T) {
- o := OptDomainNameServer{NameServers: []net.IP{net.IPv4(192, 168, 0, 1), net.IPv4(192, 168, 0, 10)}}
- require.Equal(t, "Domain Name Servers -> 192.168.0.1, 192.168.0.10", o.String())
-}