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

Function testFileContainingSymbol

reflection/test/serverreflection_test.go:556–604  ·  view source on GitHub ↗
(t *testing.T, stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoClient)

Source from the content-addressed store, hash-verified

554}
555
556func testFileContainingSymbol(t *testing.T, stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoClient) {
557 for _, test := range []struct {
558 symbol string
559 want []byte
560 }{
561 {"grpc.testing.SearchService", fdTestByte},
562 {"grpc.testing.SearchService.Search", fdTestByte},
563 {"grpc.testing.SearchService.StreamingSearch", fdTestByte},
564 {"grpc.testing.SearchResponse", fdTestByte},
565 {"grpc.testing.ToBeExtended", fdProto2Byte},
566 // Test support package v3.
567 {"grpc.testingv3.SearchServiceV3", fdTestv3Byte},
568 {"grpc.testingv3.SearchServiceV3.Search", fdTestv3Byte},
569 {"grpc.testingv3.SearchServiceV3.StreamingSearch", fdTestv3Byte},
570 {"grpc.testingv3.SearchResponseV3", fdTestv3Byte},
571 // search for field, oneof, enum, and enum value symbols, too
572 {"grpc.testingv3.SearchResponseV3.Result.snippets", fdTestv3Byte},
573 {"grpc.testingv3.SearchResponseV3.Result.Value.val", fdTestv3Byte},
574 {"grpc.testingv3.SearchResponseV3.Result.Value.str", fdTestv3Byte},
575 {"grpc.testingv3.SearchResponseV3.State", fdTestv3Byte},
576 {"grpc.testingv3.SearchResponseV3.FRESH", fdTestv3Byte},
577 // Test dynamic symbols
578 {"grpc.testing.DynamicService", fdDynamicByte},
579 {"grpc.testing.DynamicReq", fdDynamicByte},
580 {"grpc.testing.DynamicRes", fdDynamicByte},
581 } {
582 if err := stream.Send(&v1reflectionpb.ServerReflectionRequest{
583 MessageRequest: &v1reflectionpb.ServerReflectionRequest_FileContainingSymbol{
584 FileContainingSymbol: test.symbol,
585 },
586 }); err != nil {
587 t.Fatalf("failed to send request: %v", err)
588 }
589 r, err := stream.Recv()
590 if err != nil {
591 // io.EOF is not ok.
592 t.Fatalf("failed to recv response: %v", err)
593 }
594
595 switch r.MessageResponse.(type) {
596 case *v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse:
597 if !reflect.DeepEqual(r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want) {
598 t.Errorf("FileContainingSymbol(%v)\nreceived: %q,\nwant: %q", test.symbol, r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want)
599 }
600 default:
601 t.Errorf("FileContainingSymbol(%v) = %v, want type <ServerReflectionResponse_FileDescriptorResponse>", test.symbol, r.MessageResponse)
602 }
603 }
604}
605
606func testFileContainingSymbolError(t *testing.T, stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoClient) {
607 for _, test := range []string{

Callers 1

TestReflectionEnd2endMethod · 0.85

Calls 5

SendMethod · 0.65
FatalfMethod · 0.65
RecvMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected