diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-02-02 09:32:00 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-02-02 09:32:00 -0500 |
commit | 701d1ab638b23c24877fc41824add66232446676 (patch) | |
tree | ec120c88d38ac9d38d9eabdd3270b52bb6ac9d96 /vendor/github.com/miekg/dns/server_test.go | |
parent | ca3211bc04f6dea34e8168217182637d1419f998 (diff) | |
download | chat-701d1ab638b23c24877fc41824add66232446676.tar.gz chat-701d1ab638b23c24877fc41824add66232446676.tar.bz2 chat-701d1ab638b23c24877fc41824add66232446676.zip |
Updating server dependancies (#5249)
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") +} |