INNER CODE UNIT · Go
TestQuery
machinebox/graphql · graphql_multipart_test.go:196
func TestQuery(t *testing.T) {
is := is.New(t)
var calls int
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls++
query := r.FormValue("query")
is.Equal(query, "query {}")
is.Equal(r.FormValue("variables"), `{"username":"matryer"}`+"\n")
_, err := io.WriteString(w, `{"data":{"value":"some data"}}`)
is.NoErr(err)
}))
defer srv.Close()
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
client := NewClient(srv.URL, UseMultipartForm())