MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / TestServeMux_InjectPattern

Function TestServeMux_InjectPattern

runtime/mux_test.go:936–957  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

934}
935
936func TestServeMux_InjectPattern(t *testing.T) {
937 mux := runtime.NewServeMux()
938 err := mux.HandlePath("GET", "/test", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
939 p, ok := runtime.HTTPPattern(r.Context())
940 if !ok {
941 t.Errorf("pattern is not injected")
942 }
943 if p.String() != "/test" {
944 t.Errorf("pattern not /test")
945 }
946 })
947 if err != nil {
948 t.Errorf("The route test with method GET and path /test invalid, got %v", err)
949 }
950
951 r := httptest.NewRequest("GET", "/test", nil)
952 w := httptest.NewRecorder()
953 mux.ServeHTTP(w, r)
954 if w.Code != 200 {
955 t.Errorf("request not processed")
956 }
957}
958
959func TestServeHTTP_WithDisableHTTPMethodOverride(t *testing.T) {
960 // When WithDisableHTTPMethodOverride is set, X-HTTP-Method-Override

Callers

nothing calls this directly

Calls 5

HandlePathMethod · 0.95
ServeHTTPMethod · 0.95
NewServeMuxFunction · 0.92
HTTPPatternFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected