From 203525c031f7631969a037d7eff7460dbdf2c341 Mon Sep 17 00:00:00 2001 From: gertd Date: Fri, 10 Apr 2020 16:48:11 -0700 Subject: [PATCH] pr bug/rest-204 review feedback --- api/client.go | 2 +- api/client_rest_test.go | 23 ----------------------- api/client_test.go | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 api/client_rest_test.go diff --git a/api/client.go b/api/client.go index d0be883bd..2fc72aaa6 100644 --- a/api/client.go +++ b/api/client.go @@ -146,7 +146,7 @@ func (c Client) REST(method string, p string, body io.Reader, data interface{}) return handleHTTPError(resp) } - if resp.StatusCode == http.StatusNoContent && resp.ContentLength == 0 { + if resp.StatusCode == http.StatusNoContent { return nil } diff --git a/api/client_rest_test.go b/api/client_rest_test.go deleted file mode 100644 index 1d52a0220..000000000 --- a/api/client_rest_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package api - -import ( - "bytes" - "testing" -) - -func TestRESTGetDelete(t *testing.T) { - http := &FakeHTTP{} - - client := NewClient( - ReplaceTripper(http), - AddHeader("Authorization", "Basic BASE64ENCODE_CLIENT_ID:CLIENT_SECRET"), - AddHeader("Content-Type", "text/plain"), - ) - - http.StubResponse(204, bytes.NewBuffer([]byte{})) - - r := bytes.NewReader([]byte(`{"access_token": "ACCESS_TOKEN"}`)) - var data interface{} - err := client.REST("DELETE", "applications/CLIENTID/grant", r, &data) - eq(t, err, nil) -} diff --git a/api/client_test.go b/api/client_test.go index 12bfbe408..492609e5c 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -50,3 +50,17 @@ func TestGraphQLError(t *testing.T) { t.Fatalf("got %q", err.Error()) } } + +func TestRESTGetDelete(t *testing.T) { + http := &FakeHTTP{} + + client := NewClient( + ReplaceTripper(http), + ) + + http.StubResponse(204, bytes.NewBuffer([]byte{})) + + r := bytes.NewReader([]byte(`{}`)) + err := client.REST("DELETE", "applications/CLIENTID/grant", r, nil) + eq(t, err, nil) +}