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

Function TestWithHealthzEndpoint_header

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

Source from the content-addressed store, hash-verified

855}
856
857func TestWithHealthzEndpoint_header(t *testing.T) {
858 for _, tt := range healthCheckTests {
859 t.Run(tt.name, func(t *testing.T) {
860 mux := runtime.NewServeMux(runtime.WithHealthzEndpoint(&dummyHealthCheckClient{status: tt.status, code: tt.code}))
861
862 r := httptest.NewRequest(http.MethodGet, "/healthz", nil)
863 rr := httptest.NewRecorder()
864
865 mux.ServeHTTP(rr, r)
866
867 if actualHeader := rr.Header().Get("Content-Type"); actualHeader != "application/json" {
868 t.Errorf(
869 "result http header Content-Type for grpc code %q and status %q should be application/json, got %s",
870 tt.code, tt.status, actualHeader,
871 )
872 }
873 })
874 }
875}
876
877var _ grpc_health_v1.HealthClient = (*dummyHealthCheckClient)(nil)
878

Callers

nothing calls this directly

Calls 4

ServeHTTPMethod · 0.95
NewServeMuxFunction · 0.92
WithHealthzEndpointFunction · 0.92
HeaderMethod · 0.80

Tested by

no test coverage detected