MCPcopy
hub / github.com/grpc/grpc-go / TestGRPCMethod

Method TestGRPCMethod

test/end2end_test.go:5174–5204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5172}
5173
5174func (s) TestGRPCMethod(t *testing.T) {
5175 mu := sync.Mutex{}
5176 var method string
5177 var ok bool
5178
5179 ss := &stubserver.StubServer{
5180 EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
5181 mu.Lock()
5182 defer mu.Unlock()
5183 method, ok = grpc.Method(ctx)
5184 return &testpb.Empty{}, nil
5185 },
5186 }
5187 if err := ss.Start(nil); err != nil {
5188 t.Fatalf("Error starting endpoint server: %v", err)
5189 }
5190 defer ss.Stop()
5191
5192 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
5193 defer cancel()
5194
5195 if _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}); err != nil {
5196 t.Fatalf("ss.Client.EmptyCall(_, _) = _, %v; want _, nil", err)
5197 }
5198
5199 mu.Lock()
5200 defer mu.Unlock()
5201 if want := "/grpc.testing.TestService/EmptyCall"; !ok || method != want {
5202 t.Fatalf("grpc.Method(_) = %q, %v; want %q, true", method, ok, want)
5203 }
5204}
5205
5206func (s) TestUnaryProxyDoesNotForwardMetadata(t *testing.T) {
5207 const mdkey = "somedata"

Callers

nothing calls this directly

Calls 7

StartMethod · 0.95
StopMethod · 0.95
MethodFunction · 0.92
FatalfMethod · 0.65
EmptyCallMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected