Skip to content

Commit

Permalink
Adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
ddouglas committed Jun 14, 2020
1 parent 4a62f01 commit e19d43b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions graphql/handler/transport/http_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ func TestGET(t *testing.T) {
assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String())
})

t.Run("has json content-type header", func(t *testing.T) {
resp := doRequest(h, "GET", "/graphql?query={name}", ``)
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
})

t.Run("decode failure", func(t *testing.T) {
resp := doRequest(h, "GET", "/graphql?query={name}&variables=notjson", "")
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
Expand All @@ -42,4 +47,5 @@ func TestGET(t *testing.T) {
assert.Equal(t, http.StatusNotAcceptable, resp.Code, resp.Body.String())
assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String())
})

}

0 comments on commit e19d43b

Please sign in to comment.