aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar nathannaveen <42319948+nathannaveen@users.noreply.github.com> 2022-03-14 10:55:25 -0400
committerGravatar GitHub <noreply@github.com> 2022-03-14 07:55:25 -0700
commit188077d7fc8738ca794babf033de8441e18a9aa4 (patch)
treec964ab608f06a05c74c8f07e296d79aa8cbdb526
parent74830b35fd0acf6147a79c2e235beecb7c3972eb (diff)
downloadcoredns-188077d7fc8738ca794babf033de8441e18a9aa4.tar.gz
coredns-188077d7fc8738ca794babf033de8441e18a9aa4.tar.zst
coredns-188077d7fc8738ca794babf033de8441e18a9aa4.zip
Unit tests: dnsserver/https (#5251)
- Added unit tests for dnsserver/https. Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
-rw-r--r--core/dnsserver/https_test.go90
1 files changed, 90 insertions, 0 deletions
diff --git a/core/dnsserver/https_test.go b/core/dnsserver/https_test.go
new file mode 100644
index 000000000..00ed366d7
--- /dev/null
+++ b/core/dnsserver/https_test.go
@@ -0,0 +1,90 @@
+package dnsserver
+
+import (
+ "net"
+ "net/http"
+ "reflect"
+ "testing"
+)
+
+func TestDoHWriter_LocalAddr(t *testing.T) {
+ tests := []struct {
+ name string
+ laddr net.Addr
+ want net.Addr
+ }{
+ {
+ name: "LocalAddr",
+ laddr: &net.TCPAddr{},
+ want: &net.TCPAddr{},
+ },
+ {
+ name: "LocalAddr",
+ laddr: &net.UDPAddr{},
+ want: &net.UDPAddr{},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DoHWriter{
+ laddr: tt.laddr,
+ }
+ if got := d.LocalAddr(); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("LocalAddr() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestDoHWriter_RemoteAddr(t *testing.T) {
+ tests := []struct {
+ name string
+ want net.Addr
+ raddr net.Addr
+ }{
+ {
+ name: "RemoteAddr",
+ want: &net.TCPAddr{},
+ raddr: &net.TCPAddr{},
+ },
+ {
+ name: "RemoteAddr",
+ want: &net.UDPAddr{},
+ raddr: &net.UDPAddr{},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DoHWriter{
+ raddr: tt.raddr,
+ }
+ if got := d.RemoteAddr(); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("RemoteAddr() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestDoHWriter_Request(t *testing.T) {
+ tests := []struct {
+ name string
+ request *http.Request
+ want *http.Request
+ }{
+ {
+ name: "Request",
+ request: &http.Request{},
+ want: &http.Request{},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &DoHWriter{
+ request: tt.request,
+ }
+ if got := d.Request(); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Request() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}