From afa0cfa31b0181d8388e62b72e53dfa496121ad6 Mon Sep 17 00:00:00 2001 From: Andy McCall Date: Wed, 13 Mar 2019 09:36:36 -0400 Subject: [PATCH] added empty body test --- zendesk/error_test.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/zendesk/error_test.go b/zendesk/error_test.go index 15591135..07c68d5e 100644 --- a/zendesk/error_test.go +++ b/zendesk/error_test.go @@ -17,8 +17,24 @@ func TestError_Error(t *testing.T) { resp: resp, } - if err.Error() != fmt.Sprintf("%d: %s", status, body) { - t.Fatal("Error did not have expected value") + expected := fmt.Sprintf("%d: %s", status, body) + if v := err.Error(); v != expected { + t.Fatalf("Error %s did not have expected value %s", v, expected) + } +} + +func TestError_ErrorEmptyBody(t *testing.T) { + status := http.StatusOK + resp := &http.Response{ + StatusCode: status, + } + err := Error{ + resp: resp, + } + + expected := fmt.Sprintf("%d: %s", status, http.StatusText(status)) + if v := err.Error(); v != expected { + t.Fatalf("Error %s did not have expected value %s", v, expected) } }