diff options
Diffstat (limited to 'vendor/github.com/miekg/dns/server_test.go')
-rw-r--r-- | vendor/github.com/miekg/dns/server_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/miekg/dns/server_test.go b/vendor/github.com/miekg/dns/server_test.go index 1b5cbc97e..098be2ebe 100644 --- a/vendor/github.com/miekg/dns/server_test.go +++ b/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") +} |