@@ -481,3 +481,98 @@ func TestAllowPatchFeature(t *testing.T) {
481481 }
482482 }
483483}
484+
485+ func TestIdentifierCapitalization (t * testing.T ){
486+ msgdesc1 := & protodescriptor.DescriptorProto {
487+ Name : proto .String ("Exam_pleRequest" ),
488+ }
489+ msgdesc2 := & protodescriptor.DescriptorProto {
490+ Name : proto .String ("example_response" ),
491+ }
492+ meth1 := & protodescriptor.MethodDescriptorProto {
493+ Name : proto .String ("ExampleGe2t" ),
494+ InputType : proto .String ("Exam_pleRequest" ),
495+ OutputType : proto .String ("example_response" ),
496+ }
497+ meth2 := & protodescriptor.MethodDescriptorProto {
498+ Name : proto .String ("Exampl_eGet" ),
499+ InputType : proto .String ("Exam_pleRequest" ),
500+ OutputType : proto .String ("example_response" ),
501+ }
502+ svc := & protodescriptor.ServiceDescriptorProto {
503+ Name : proto .String ("Example" ),
504+ Method : []* protodescriptor.MethodDescriptorProto {meth1 , meth2 },
505+ }
506+ msg1 := & descriptor.Message {
507+ DescriptorProto : msgdesc1 ,
508+ }
509+ msg2 := & descriptor.Message {
510+ DescriptorProto : msgdesc2 ,
511+ }
512+ file := descriptor.File {
513+ FileDescriptorProto : & protodescriptor.FileDescriptorProto {
514+ Name : proto .String ("example.proto" ),
515+ Package : proto .String ("example" ),
516+ Dependency : []string {"a.example/b/c.proto" , "a.example/d/e.proto" },
517+ MessageType : []* protodescriptor.DescriptorProto {msgdesc1 , msgdesc2 },
518+ Service : []* protodescriptor.ServiceDescriptorProto {svc },
519+ },
520+ GoPkg : descriptor.GoPackage {
521+ Path : "example.com/path/to/example/example.pb" ,
522+ Name : "example_pb" ,
523+ },
524+ Messages : []* descriptor.Message {msg1 , msg2 },
525+ Services : []* descriptor.Service {
526+ {
527+ ServiceDescriptorProto : svc ,
528+ Methods : []* descriptor.Method {
529+ {
530+ MethodDescriptorProto : meth1 ,
531+ RequestType : msg1 ,
532+ ResponseType : msg1 ,
533+ Bindings : []* descriptor.Binding {
534+ {
535+ HTTPMethod : "GET" ,
536+ Body : & descriptor.Body {FieldPath : nil },
537+ },
538+ },
539+ },
540+ },
541+ },
542+ {
543+ ServiceDescriptorProto : svc ,
544+ Methods : []* descriptor.Method {
545+ {
546+ MethodDescriptorProto : meth2 ,
547+ RequestType : msg2 ,
548+ ResponseType : msg2 ,
549+ Bindings : []* descriptor.Binding {
550+ {
551+ HTTPMethod : "GET" ,
552+ Body : & descriptor.Body {FieldPath : nil },
553+ },
554+ },
555+ },
556+ },
557+ },
558+ },
559+ }
560+
561+ got , err := applyTemplate (param {File : crossLinkFixture (& file ), RegisterFuncSuffix : "Handler" , AllowPatchFeature : true }, descriptor .NewRegistry ())
562+ if err != nil {
563+ t .Errorf ("applyTemplate(%#v) failed with %v; want success" , file , err )
564+ return
565+ }
566+ if want := `msg, err := client.ExampleGe2T(ctx, &protoReq, grpc.Header(&metadata.HeaderMD)` ; ! strings .Contains (got , want ) {
567+ t .Errorf ("applyTemplate(%#v) = %s; want to contain %s" , file , got , want )
568+ }
569+ if want := `msg, err := client.ExamplEGet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD)` ; ! strings .Contains (got , want ) {
570+ t .Errorf ("applyTemplate(%#v) = %s; want to contain %s" , file , got , want )
571+ }
572+ if want := `var protoReq ExamPleRequest` ; ! strings .Contains (got , want ) {
573+ t .Errorf ("applyTemplate(%#v) = %s; want to contain %s" , file , got , want )
574+ }
575+ if want := `var protoReq ExampleResponse` ; ! strings .Contains (got , want ) {
576+ t .Errorf ("applyTemplate(%#v) = %s; want to contain %s" , file , got , want )
577+ }
578+ }
0 commit comments