@@ -37,6 +37,15 @@ func crossLinkFixture(f *descriptor.File) *descriptor.File {
3737 return f
3838}
3939
40+ func reqFromFile (f * descriptor.File ) * plugin.CodeGeneratorRequest {
41+ return & plugin.CodeGeneratorRequest {
42+ ProtoFile : []* protodescriptor.FileDescriptorProto {
43+ f .FileDescriptorProto ,
44+ },
45+ FileToGenerate : []string {f .GetName ()},
46+ }
47+ }
48+
4049func TestMessageToQueryParameters (t * testing.T ) {
4150 type test struct {
4251 MsgDescs []* protodescriptor.DescriptorProto
@@ -381,7 +390,14 @@ func TestApplyTemplateSimple(t *testing.T) {
381390 },
382391 },
383392 }
384- result , err := applyTemplate (param {File : crossLinkFixture (& file ), reg : descriptor .NewRegistry ()})
393+ reg := descriptor .NewRegistry ()
394+ fileCL := crossLinkFixture (& file )
395+ err := reg .Load (reqFromFile (fileCL ))
396+ if err != nil {
397+ t .Errorf ("reg.Load(%#v) failed with %v; want success" , file , err )
398+ return
399+ }
400+ result , err := applyTemplate (param {File : fileCL , reg : reg })
385401 if err != nil {
386402 t .Errorf ("applyTemplate(%#v) failed with %v; want success" , file , err )
387403 return
@@ -471,7 +487,15 @@ func TestApplyTemplateOverrideOperationID(t *testing.T) {
471487 },
472488 },
473489 }
474- result , err := applyTemplate (param {File : crossLinkFixture (& file ), reg : descriptor .NewRegistry ()})
490+
491+ reg := descriptor .NewRegistry ()
492+ fileCL := crossLinkFixture (& file )
493+ err := reg .Load (reqFromFile (fileCL ))
494+ if err != nil {
495+ t .Errorf ("reg.Load(%#v) failed with %v; want success" , file , err )
496+ return
497+ }
498+ result , err := applyTemplate (param {File : fileCL , reg : reg })
475499 if err != nil {
476500 t .Errorf ("applyTemplate(%#v) failed with %v; want success" , file , err )
477501 return
@@ -585,7 +609,14 @@ func TestApplyTemplateExtensions(t *testing.T) {
585609 if err := proto .SetExtension (proto .Message (meth .Options ), swagger_options .E_Openapiv2Operation , & swaggerOperation ); err != nil {
586610 t .Fatalf ("proto.SetExtension(MethodDescriptorProto.Options) failed: %v" , err )
587611 }
588- result , err := applyTemplate (param {File : crossLinkFixture (& file ), reg : descriptor .NewRegistry ()})
612+ reg := descriptor .NewRegistry ()
613+ fileCL := crossLinkFixture (& file )
614+ err := reg .Load (reqFromFile (fileCL ))
615+ if err != nil {
616+ t .Errorf ("reg.Load(%#v) failed with %v; want success" , file , err )
617+ return
618+ }
619+ result , err := applyTemplate (param {File : fileCL , reg : reg })
589620 if err != nil {
590621 t .Errorf ("applyTemplate(%#v) failed with %v; want success" , file , err )
591622 return
0 commit comments