INNER CODE UNIT · Go
srv
machinebox/graphql · graphql_json_test.go:18
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls++
is.Equal(r.Method, http.MethodPost)
b, err := ioutil.ReadAll(r.Body)
is.NoErr(err)
is.Equal(string(b), `{"query":"query {}","variables":null}`+"\n")
io.WriteString(w, `{
"data": {
"something": "yes"
}
}`)
}))
defer srv.Close()
ctx := context.Background()
client := NewClient(srv.URL)
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)