summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-09-27 13:19:11 +0100
committerAndrea Barberio <insomniac@slackware.it>2018-09-27 13:19:11 +0100
commitde8157f8da4ae7516c90d7846cb327daa209f579 (patch)
tree98a1a716892746b939232455d0d88882da49979c
parent1d55b46a34be2b6776c438b5425a3e0afb9d9905 (diff)
Added client and server constructor tests
-rw-r--r--dhcpv6/client_test.go14
-rw-r--r--dhcpv6/server_test.go21
2 files changed, 35 insertions, 0 deletions
diff --git a/dhcpv6/client_test.go b/dhcpv6/client_test.go
new file mode 100644
index 0000000..d2efa1f
--- /dev/null
+++ b/dhcpv6/client_test.go
@@ -0,0 +1,14 @@
+package dhcpv6
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestNewClient(t *testing.T) {
+ c := NewClient()
+ require.NotNil(t, c)
+ require.Equal(t, DefaultReadTimeout, c.ReadTimeout)
+ require.Equal(t, DefaultWriteTimeout, c.WriteTimeout)
+}
diff --git a/dhcpv6/server_test.go b/dhcpv6/server_test.go
new file mode 100644
index 0000000..3794a4f
--- /dev/null
+++ b/dhcpv6/server_test.go
@@ -0,0 +1,21 @@
+package dhcpv6
+
+import (
+ "net"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestNewServer(t *testing.T) {
+ laddr := net.UDPAddr{
+ IP: net.ParseIP("::1"),
+ Port: 0,
+ }
+ handler := func(conn net.PacketConn, peer net.Addr, m DHCPv6) {}
+ s := NewServer(laddr, handler)
+ require.NotNil(t, s)
+ require.Nil(t, s.conn)
+ require.Equal(t, laddr, s.LocalAddr)
+ require.NotNil(t, s.Handler)
+}