From c20e9bff2623f6c0eba44856a7a37d52aa00f3db Mon Sep 17 00:00:00 2001 From: Chris Hines Date: Wed, 2 Dec 2015 13:59:27 -0500 Subject: [PATCH] Do not leak listeners in test. --- command/agent/config_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index c13ff91f3..961ae9363 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -292,13 +292,16 @@ func TestConfig_Listener(t *testing.T) { config := DefaultConfig() // Fails on invalid input - if _, err := config.Listener("tcp", "nope", 8080); err == nil { + if ln, err := config.Listener("tcp", "nope", 8080); err == nil { + ln.Close() t.Fatalf("expected addr error") } - if _, err := config.Listener("nope", "127.0.0.1", 8080); err == nil { + if ln, err := config.Listener("nope", "127.0.0.1", 8080); err == nil { + ln.Close() t.Fatalf("expected protocol err") } - if _, err := config.Listener("tcp", "127.0.0.1", -1); err == nil { + if ln, err := config.Listener("tcp", "127.0.0.1", -1); err == nil { + ln.Close() t.Fatalf("expected port error") }