MCPcopy
hub / github.com/dosco/graphjin / TestCallerRowJoinPath

Function TestCallerRowJoinPath

core/openapi/caller_test.go:23–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestCallerRowJoinPath(t *testing.T) {
24 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
25 // RequestURI carries the escaped wire form; r.URL.Path is the
26 // decoded version. Asserting on RequestURI ensures the client
27 // actually escaped the space rather than relying on the server
28 // to be lenient.
29 if r.RequestURI != "/users/abc%20123" {
30 t.Errorf("RequestURI = %q, want /users/abc%%20123", r.RequestURI)
31 }
32 w.Header().Set("Content-Type", "application/json")
33 _, _ = w.Write([]byte(`{"id":"abc 123","email":"u@x"}`))
34 }))
35 defer srv.Close()
36
37 op := &OpDescriptor{
38 OperationID: "getUserById",
39 Method: "GET",
40 PathTemplate: "/users/{userId}",
41 PathParams: []ParamSpec{{Name: "userId", In: ParamInPath, Required: true, Type: "string"}},
42 }
43 c := buildCaller(t, op, srv.URL, nil)
44
45 body, err := c.Call(context.Background(), CallParams{
46 PathValues: map[string]string{"userId": "abc 123"},
47 })
48 if err != nil {
49 t.Fatalf("Call: %v", err)
50 }
51 if !contains(string(body), `"abc 123"`) {
52 t.Errorf("body = %s", body)
53 }
54}
55
56func TestCallerListWithQueryParams(t *testing.T) {
57 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

buildCallerFunction · 0.85
containsFunction · 0.70
SetMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65
CallMethod · 0.65

Tested by

no test coverage detected