From f504aca90fa16f6c507dddcfceb707ab1571e761 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sun, 19 Apr 2015 13:17:25 -0700 Subject: [PATCH] http: split testing methods --- http/testing.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/http/testing.go b/http/testing.go index 1a2950eda9..5c6f980032 100644 --- a/http/testing.go +++ b/http/testing.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/vault/vault" ) -func TestServer(t *testing.T, core *vault.Core) (net.Listener, string) { +func TestListener(t *testing.T) (net.Listener, string) { fail := func(format string, args ...interface{}) { panic(fmt.Sprintf(format, args...)) } @@ -24,7 +24,10 @@ func TestServer(t *testing.T, core *vault.Core) (net.Listener, string) { fail("err: %s", err) } addr := "http://" + ln.Addr().String() + return ln, addr +} +func TestServerWithListener(t *testing.T, ln net.Listener, addr string, core *vault.Core) { // Create a muxer to handle our requests so that we can authenticate // for tests. mux := http.NewServeMux() @@ -36,7 +39,11 @@ func TestServer(t *testing.T, core *vault.Core) (net.Listener, string) { Handler: mux, } go server.Serve(ln) +} +func TestServer(t *testing.T, core *vault.Core) (net.Listener, string) { + ln, addr := TestListener(t) + TestServerWithListener(t, ln, addr, core) return ln, addr }