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

Function testFileByFilename

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

Source from the content-addressed store, hash-verified

493}
494
495func testFileByFilename(t *testing.T, stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoClient) {
496 for _, test := range []struct {
497 filename string
498 want []byte
499 }{
500 {"reflection/grpc_testing/test.proto", fdTestByte},
501 {"reflection/grpc_testing/proto2.proto", fdProto2Byte},
502 {"reflection/grpc_testing/proto2_ext.proto", fdProto2ExtByte},
503 {"dynamic.proto", fdDynamicByte},
504 } {
505 if err := stream.Send(&v1reflectionpb.ServerReflectionRequest{
506 MessageRequest: &v1reflectionpb.ServerReflectionRequest_FileByFilename{
507 FileByFilename: test.filename,
508 },
509 }); err != nil {
510 t.Fatalf("failed to send request: %v", err)
511 }
512 r, err := stream.Recv()
513 if err != nil {
514 // io.EOF is not ok.
515 t.Fatalf("failed to recv response: %v", err)
516 }
517
518 switch r.MessageResponse.(type) {
519 case *v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse:
520 if !reflect.DeepEqual(r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want) {
521 t.Errorf("FileByFilename(%v)\nreceived: %q,\nwant: %q", test.filename, r.GetFileDescriptorResponse().FileDescriptorProto[0], test.want)
522 }
523 default:
524 t.Errorf("FileByFilename(%v) = %v, want type <ServerReflectionResponse_FileDescriptorResponse>", test.filename, r.MessageResponse)
525 }
526 }
527}
528
529func testFileByFilenameError(t *testing.T, stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoClient) {
530 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