From 6d4930da93cadc4e3e61f997758a5c16899506e7 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Fri, 20 Sep 2019 15:52:02 -0400 Subject: [PATCH] Dont crash in the testutil server creation (#6516) --- sdk/testutil/server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/testutil/server.go b/sdk/testutil/server.go index 958017ec27..53483d38d6 100644 --- a/sdk/testutil/server.go +++ b/sdk/testutil/server.go @@ -263,8 +263,11 @@ func newTestServerConfigT(t *testing.T, cb ServerConfigCallback) (*TestServer, e os.RemoveAll(tmpdir) return nil, errors.Wrap(err, "failed marshaling json") } - - t.Logf("CONFIG JSON: %s", string(b)) + + if t != nil { + // if you really want this output ensure to pass a valid t + t.Logf("CONFIG JSON: %s", string(b)) + } configFile := filepath.Join(tmpdir, "config.json") if err := ioutil.WriteFile(configFile, b, 0644); err != nil { cfg.ReturnPorts()