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

Method TestMethodFromServerStream

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

Source from the content-addressed store, hash-verified

5621}
5622
5623func (s) TestMethodFromServerStream(t *testing.T) {
5624 const testMethod = "/package.service/method"
5625 e := tcpClearRREnv
5626 te := newTest(t, e)
5627 var mu sync.Mutex
5628 var method string
5629 var ok bool
5630 te.unknownHandler = func(_ any, stream grpc.ServerStream) error {
5631 mu.Lock()
5632 defer mu.Unlock()
5633 method, ok = grpc.MethodFromServerStream(stream)
5634 return nil
5635 }
5636
5637 te.startServer(nil)
5638 defer te.tearDown()
5639 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
5640 defer cancel()
5641 _ = te.clientConn().Invoke(ctx, testMethod, nil, nil)
5642 mu.Lock()
5643 defer mu.Unlock()
5644 if !ok || method != testMethod {
5645 t.Fatalf("Invoke with method %q, got %q, %v, want %q, true", testMethod, method, ok, testMethod)
5646 }
5647}
5648
5649func (s) TestInterceptorCanAccessCallOptions(t *testing.T) {
5650 e := tcpClearRREnv

Callers

nothing calls this directly

Calls 9

MethodFromServerStreamFunction · 0.92
newTestFunction · 0.70
InvokeMethod · 0.65
FatalfMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected