From 4d294889da3432ec5e9bd790570e3c0801da0d5c Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 5 Jul 2017 10:51:27 +0300 Subject: [PATCH] Log response body if test fails. --- node_exporter_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node_exporter_test.go b/node_exporter_test.go index d1830ec2..3b579492 100644 --- a/node_exporter_test.go +++ b/node_exporter_test.go @@ -93,11 +93,15 @@ func queryExporter(address string) error { if err != nil { return err } + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } if err := resp.Body.Close(); err != nil { return err } if want, have := http.StatusOK, resp.StatusCode; want != have { - return fmt.Errorf("want /metrics status code %d, have %d", want, have) + return fmt.Errorf("want /metrics status code %d, have %d. Body:\n%s", want, have, b) } return nil }