@@ -494,108 +494,10 @@ func Test_Encoding_BindQuery(t *testing.T) {
494494 }
495495}
496496
497- // Deprecated: Because BindUri is deprecated.
498497func Test_Encoding_BindUri (t * testing.T ) {
499498 registry := New ()
500499 require .NoError (t , registry .Register (MIMEURI , form .New ("json" )))
501500
502- tests := []struct {
503- name string
504- genReq func () (* http.Request , error )
505- want any
506- wantErr bool
507- }{
508- {
509- "uri - no proto" ,
510- func () (* http.Request , error ) {
511- r , err := http .NewRequest (http .MethodGet , "http://example.com/foo/bar" , nil )
512- if err != nil {
513- return nil , err
514- }
515-
516- param := url.Values {}
517- param .Add ("id" , "foo" )
518- param .Add ("name" , "bar" )
519- return RequestWithUri (r , param ), nil
520- },
521- & TestMode {
522- Id : "foo" ,
523- Name : "bar" ,
524- },
525- false ,
526- },
527- {
528- "uri - proto" ,
529- func () (* http.Request , error ) {
530- r , err := http .NewRequest (http .MethodGet , "http://example.com?id=11&uint32=1234&bool=true" , nil )
531- if err != nil {
532- return nil , err
533- }
534- param := url.Values {}
535- param .Add ("id" , "11" )
536- param .Add ("uint32" , "1234" )
537- param .Add ("bool" , "true" )
538- return RequestWithUri (r , param ), nil
539- },
540- & examplepb.Complex {
541- Id : 11 ,
542- Uint32 : wrapperspb .UInt32 (1234 ),
543- Bool : wrapperspb .Bool (true ),
544- },
545- false ,
546- },
547- {
548- "uri - always in context" ,
549- func () (* http.Request , error ) {
550- r , err := http .NewRequest (http .MethodGet , "http://example.com?id=11&uint32=1234&bool=true" , nil )
551- if err != nil {
552- return nil , err
553- }
554- r .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
555- return RequestWithUri (r , nil ), nil
556- },
557- & examplepb.Complex {},
558- false ,
559- },
560- {
561- "uri - no existing in context" ,
562- func () (* http.Request , error ) {
563- r , err := http .NewRequest (http .MethodGet , "http://example.com?id=11&uint32=1234&bool=true" , nil )
564- if err != nil {
565- return nil , err
566- }
567- r .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
568- return r , nil
569- },
570- & examplepb.Complex {},
571- true ,
572- },
573- }
574- for _ , tt := range tests {
575- t .Run (tt .name , func (t * testing.T ) {
576- req , err := tt .genReq ()
577- if err != nil {
578- t .Errorf ("genReq() error = %v" , err )
579- }
580- got := alloc (reflect .TypeOf (tt .want ))
581- if err = registry .BindUri (req , got .Interface ()); (err != nil ) != tt .wantErr {
582- t .Errorf ("BindUri() error = %v, wantErr %v" , err , tt .wantErr )
583- }
584- if _ , ok := tt .want .(proto.Message ); ok {
585- if diff := proto .Equal (got .Interface ().(proto.Message ), tt .want .(proto.Message )); ! diff {
586- t .Errorf ("got = %v, want %v" , got , tt .want )
587- }
588- } else {
589- require .Equal (t , got .Interface (), tt .want )
590- }
591- })
592- }
593- }
594-
595- func Test_Encoding_BindURI (t * testing.T ) {
596- registry := New ()
597- require .NoError (t , registry .Register (MIMEURI , form .New ("json" )))
598-
599501 tests := []struct {
600502 name string
601503 genUri func () (url.Values , error )
@@ -640,7 +542,7 @@ func Test_Encoding_BindURI(t *testing.T) {
640542 t .Errorf ("genUri() error = %v" , err )
641543 }
642544 got := alloc (reflect .TypeOf (tt .want ))
643- if err = registry .BindURI (raws , got .Interface ()); (err != nil ) != tt .wantErr {
545+ if err = registry .BindUri (raws , got .Interface ()); (err != nil ) != tt .wantErr {
644546 t .Errorf ("BindURI() error = %v, wantErr %v" , err , tt .wantErr )
645547 }
646548 if _ , ok := tt .want .(proto.Message ); ok {
0 commit comments