pr bug/rest-204 review feedback
This commit is contained in:
parent
b9f1b5dac1
commit
203525c031
3 changed files with 15 additions and 24 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue