INNER CODE UNIT · Go
TestDoServerErr
machinebox/graphql · graphql_multipart_test.go:120
func TestDoServerErr(t *testing.T) {
is := is.New(t)
var calls int
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls++
is.Equal(r.Method, http.MethodPost)
query := r.FormValue("query")
is.Equal(query, `query {}`)
w.WriteHeader(http.StatusInternalServerError)
io.WriteString(w, `Internal Server Error`)
}))
defer srv.Close()
ctx := context.Background()
client := NewClient(srv.URL, UseMultipartForm())
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()