Этот коммит содержится в:
Christopher Speller
2017-02-02 09:32:00 -05:00
коммит произвёл Harrison Healey
родитель ca3211bc04
Коммит 701d1ab638
326 изменённых файлов: 121334 добавлений и 3928 удалений

40
vendor/github.com/miekg/dns/server_test.go сгенерированный поставляемый
Просмотреть файл

@@ -677,3 +677,43 @@ zDCJkckCgYEAndqM5KXGk5xYo+MAA1paZcbTUXwaWwjLU+XSRSSoyBEi5xMtfvUb
kFsxKCqxAnBVGEWAvVZAiiTOxleQFjz5RnL0BQp9Lg2cQe+dvuUmIAA=
-----END RSA PRIVATE KEY-----`)
)
func testShutdownBindPort(t *testing.T, protocol string, port string) {
handler := NewServeMux()
handler.HandleFunc(".", func(w ResponseWriter, r *Msg) {})
startedCh := make(chan struct{})
s := &Server{
Addr: net.JoinHostPort("127.0.0.1", port),
Net: protocol,
Handler: handler,
NotifyStartedFunc: func() {
startedCh <- struct{}{}
},
}
go func() {
if err := s.ListenAndServe(); err != nil {
t.Log(err)
}
}()
<-startedCh
t.Logf("DNS server is started on: %s", s.Addr)
if err := s.Shutdown(); err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)
go func() {
if err := s.ListenAndServe(); err != nil {
t.Fatal(err)
}
}()
<-startedCh
t.Logf("DNS server is started on: %s", s.Addr)
}
func TestShutdownBindPortUDP(t *testing.T) {
testShutdownBindPort(t, "udp", "1153")
}
func TestShutdownBindPortTCP(t *testing.T) {
testShutdownBindPort(t, "tcp", "1154")
}