More unit tests #19

Merged
sam merged 5 commits from tests into master 2022-07-02 16:34:42 +00:00
Showing only changes of commit 494998b88d - Show all commits

View file

@ -2,6 +2,8 @@ package query
import (
"fmt"
"net"
"strconv"
"strings"
"testing"
@ -63,3 +65,48 @@ func Test3ResolveHTTPS(t *testing.T) {
assert.Nil(t, in)
}
func TestQuic(t *testing.T) {
var err error
testCase := util.Answers{Server: "dns.adguard.com", Request: dns.TypeA, Name: "git.froth.zone"}
testCase2 := util.Answers{Server: "dns.adguard.com", Request: dns.TypeA, Name: "git.froth.zone"}
var testCases []util.Answers
testCases = append(testCases, testCase)
testCases = append(testCases, testCase2)
for i := range testCases {
switch i {
case 0:
port := 853
testCases[i].Server = net.JoinHostPort(testCases[i].Server, strconv.Itoa(port))
fmt.Println(testCases[i].Server)
// if the domain is not canonical, make it canonical
if !strings.HasSuffix(testCase.Name, ".") {
testCases[i].Name = fmt.Sprintf("%s.", testCases[i].Name)
}
msg := new(dns.Msg)
msg.SetQuestion(testCase.Name, testCase.Request)
msg = msg.SetQuestion(testCase.Name, testCase.Request)
var in *dns.Msg
in, testCase.RTT, err = ResolveQUIC(msg, testCase.Server)
assert.NotNil(t, err)
assert.Nil(t, in)
case 1:
port := 853
testCases[i].Server = net.JoinHostPort(testCases[i].Server, strconv.Itoa(port))
// if the domain is not canonical, make it canonical
if !strings.HasSuffix(testCase.Name, ".") {
testCases[i].Name = fmt.Sprintf("%s.", testCases[i].Name)
}
msg := new(dns.Msg)
msg.SetQuestion(testCases[i].Name, testCases[i].Request)
msg = msg.SetQuestion(testCases[i].Name, testCases[i].Request)
var in *dns.Msg
in, testCase.RTT, err = ResolveQUIC(msg, testCases[i].Server)
assert.Nil(t, err)
assert.NotNil(t, in)
}
}
}