mirror of
https://github.com/joohoi/acme-dns.git
synced 2024-12-22 21:23:52 +07:00
Fixed race conditions in tests
This commit is contained in:
parent
9ebc0d02ae
commit
3ae7dee8ea
@ -5,7 +5,6 @@ import (
|
||||
"github.com/gavv/httpexpect"
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/httptest"
|
||||
"github.com/op/go-logging"
|
||||
"gopkg.in/DATA-DOG/go-sqlmock.v1"
|
||||
"testing"
|
||||
)
|
||||
@ -27,7 +26,7 @@ func SetupIris(t *testing.T, debug bool, noauth bool) *httpexpect.Expect {
|
||||
}
|
||||
DNSConf = dnscfg
|
||||
// In memory logger
|
||||
logging.InitForTesting(logging.DEBUG)
|
||||
//logging.InitForTesting(logging.DEBUG)
|
||||
err := DB.Init(DNSConf.Database.Engine, DNSConf.Database.Connection)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
14
dns_test.go
14
dns_test.go
@ -5,13 +5,13 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/op/go-logging"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var testAddr = "0.0.0.0:15353"
|
||||
var testAddr1 = "0.0.0.0:15353"
|
||||
var testAddr2 = "0.0.0.0:15354"
|
||||
|
||||
var records = []string{
|
||||
"auth.example.org. A 192.168.1.100",
|
||||
@ -96,7 +96,6 @@ func startDNSServer(addr string) (*dns.Server, resolver) {
|
||||
|
||||
DNSConf = dnscfg
|
||||
|
||||
logging.InitForTesting(logging.DEBUG)
|
||||
// DNS server part
|
||||
dns.HandleFunc(".", handleRequest)
|
||||
server := &dns.Server{Addr: addr, Net: "udp"}
|
||||
@ -111,9 +110,9 @@ func startDNSServer(addr string) (*dns.Server, resolver) {
|
||||
}
|
||||
|
||||
func TestResolveA(t *testing.T) {
|
||||
server, resolver := startDNSServer(testAddr)
|
||||
defer server.Shutdown()
|
||||
RR.Parse(records)
|
||||
server, resolver := startDNSServer(testAddr1)
|
||||
defer server.Shutdown()
|
||||
answer, err := resolver.lookup("auth.example.org", dns.TypeA)
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
@ -128,6 +127,7 @@ func TestResolveA(t *testing.T) {
|
||||
} else {
|
||||
t.Error("No answer for DNS query")
|
||||
}
|
||||
server.Shutdown()
|
||||
}
|
||||
|
||||
func TestResolveTXT(t *testing.T) {
|
||||
@ -145,9 +145,8 @@ func TestResolveTXT(t *testing.T) {
|
||||
}
|
||||
defer DB.DB.Close()
|
||||
|
||||
server, resolver := startDNSServer(testAddr)
|
||||
server, resolver := startDNSServer(testAddr2)
|
||||
defer server.Shutdown()
|
||||
RR.Parse(records)
|
||||
|
||||
validTXT := "______________valid_response_______________"
|
||||
|
||||
@ -204,4 +203,5 @@ func TestResolveTXT(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
server.Shutdown()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user