@@ -454,7 +454,7 @@ func TestBasic(t *testing.T) {
454454 newImage .Files (),
455455 )
456456 diff := cmp .Diff (protoImage , bufimage .ImageToProtoImage (newImage ), protocmp .Transform ())
457- require .Equal ( t , "" , diff )
457+ require .Empty ( t , diff )
458458 fileDescriptorSet := & descriptorpb.FileDescriptorSet {
459459 File : []* descriptorpb.FileDescriptorProto {
460460 testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
@@ -467,7 +467,7 @@ func TestBasic(t *testing.T) {
467467 },
468468 }
469469 diff = cmp .Diff (fileDescriptorSet , bufimage .ImageToFileDescriptorSet (image ), protocmp .Transform ())
470- require .Equal ( t , "" , diff )
470+ require .Empty ( t , diff )
471471 codeGeneratorRequest := & pluginpb.CodeGeneratorRequest {
472472 ProtoFile : []* descriptorpb.FileDescriptorProto {
473473 testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
@@ -486,21 +486,32 @@ func TestBasic(t *testing.T) {
486486 "b/b.proto" ,
487487 "d/d.proto/d.proto" ,
488488 },
489+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
490+ testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
491+ testProtoImageFileToFileDescriptorProto (protoImageFileAB ),
492+ testProtoImageFileToFileDescriptorProto (protoImageFileBA ),
493+ testProtoImageFileToFileDescriptorProto (protoImageFileBB ),
494+ testProtoImageFileToFileDescriptorProto (protoImageFileOutlandishDirectoryName ),
495+ },
489496 }
497+ actualRequest , err := bufimage .ImageToCodeGeneratorRequest (image , "foo" , nil , false , false )
498+ require .NoError (t , err )
490499 diff = cmp .Diff (
491500 codeGeneratorRequest ,
492- bufimage . ImageToCodeGeneratorRequest ( image , "foo" , nil , false , false ) ,
501+ actualRequest ,
493502 protocmp .Transform (),
494503 )
495- require .Equal ( t , "" , diff )
504+ require .Empty ( t , diff )
496505
497506 // verify that includeWellKnownTypes is a no-op if includeImports is false
507+ actualRequest , err = bufimage .ImageToCodeGeneratorRequest (image , "foo" , nil , false , true )
508+ require .NoError (t , err )
498509 diff = cmp .Diff (
499510 codeGeneratorRequest ,
500- bufimage . ImageToCodeGeneratorRequest ( image , "foo" , nil , false , true ) ,
511+ actualRequest ,
501512 protocmp .Transform (),
502513 )
503- require .Equal ( t , "" , diff )
514+ require .Empty ( t , diff )
504515
505516 codeGeneratorRequestIncludeImports := & pluginpb.CodeGeneratorRequest {
506517 ProtoFile : []* descriptorpb.FileDescriptorProto {
@@ -522,13 +533,23 @@ func TestBasic(t *testing.T) {
522533 "b/b.proto" ,
523534 "d/d.proto/d.proto" ,
524535 },
536+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
537+ testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
538+ testProtoImageFileToFileDescriptorProto (protoImageFileImport ),
539+ testProtoImageFileToFileDescriptorProto (protoImageFileAB ),
540+ testProtoImageFileToFileDescriptorProto (protoImageFileBA ),
541+ testProtoImageFileToFileDescriptorProto (protoImageFileBB ),
542+ testProtoImageFileToFileDescriptorProto (protoImageFileOutlandishDirectoryName ),
543+ },
525544 }
545+ actualRequest , err = bufimage .ImageToCodeGeneratorRequest (image , "foo" , nil , true , false )
546+ require .NoError (t , err )
526547 diff = cmp .Diff (
527548 codeGeneratorRequestIncludeImports ,
528- bufimage . ImageToCodeGeneratorRequest ( image , "foo" , nil , true , false ) ,
549+ actualRequest ,
529550 protocmp .Transform (),
530551 )
531- require .Equal ( t , "" , diff )
552+ require .Empty ( t , diff )
532553 newImage , err = bufimage .NewImageForCodeGeneratorRequest (codeGeneratorRequest )
533554 require .NoError (t , err )
534555 AssertImageFilesEqual (
@@ -564,13 +585,24 @@ func TestBasic(t *testing.T) {
564585 "b/b.proto" ,
565586 "d/d.proto/d.proto" ,
566587 },
588+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
589+ testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
590+ testProtoImageFileToFileDescriptorProto (protoImageFileImport ),
591+ testProtoImageFileToFileDescriptorProto (protoImageFileWellKnownTypeImport ),
592+ testProtoImageFileToFileDescriptorProto (protoImageFileAB ),
593+ testProtoImageFileToFileDescriptorProto (protoImageFileBA ),
594+ testProtoImageFileToFileDescriptorProto (protoImageFileBB ),
595+ testProtoImageFileToFileDescriptorProto (protoImageFileOutlandishDirectoryName ),
596+ },
567597 }
598+ actualRequest , err = bufimage .ImageToCodeGeneratorRequest (image , "foo" , nil , true , true )
599+ require .NoError (t , err )
568600 diff = cmp .Diff (
569601 codeGeneratorRequestIncludeImportsAndWellKnownTypes ,
570- bufimage . ImageToCodeGeneratorRequest ( image , "foo" , nil , true , true ) ,
602+ actualRequest ,
571603 protocmp .Transform (),
572604 )
573- require .Equal ( t , "" , diff )
605+ require .Empty ( t , diff )
574606 // imagesByDir and multiple Image tests
575607 imagesByDir , err := bufimage .ImageByDir (image )
576608 require .NoError (t , err )
@@ -618,6 +650,10 @@ func TestBasic(t *testing.T) {
618650 "a/a.proto" ,
619651 "a/b.proto" ,
620652 },
653+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
654+ testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
655+ testProtoImageFileToFileDescriptorProto (protoImageFileAB ),
656+ },
621657 },
622658 {
623659 ProtoFile : []* descriptorpb.FileDescriptorProto {
@@ -633,6 +669,10 @@ func TestBasic(t *testing.T) {
633669 "b/a.proto" ,
634670 "b/b.proto" ,
635671 },
672+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
673+ testProtoImageFileToFileDescriptorProto (protoImageFileBA ),
674+ testProtoImageFileToFileDescriptorProto (protoImageFileBB ),
675+ },
636676 },
637677 {
638678 ProtoFile : []* descriptorpb.FileDescriptorProto {
@@ -643,13 +683,17 @@ func TestBasic(t *testing.T) {
643683 FileToGenerate : []string {
644684 "d/d.proto/d.proto" ,
645685 },
686+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
687+ testProtoImageFileToFileDescriptorProto (protoImageFileOutlandishDirectoryName ),
688+ },
646689 },
647690 }
648- requestsFromImages := bufimage .ImagesToCodeGeneratorRequests (imagesByDir , "foo" , nil , false , false )
691+ requestsFromImages , err := bufimage .ImagesToCodeGeneratorRequests (imagesByDir , "foo" , nil , false , false )
692+ require .NoError (t , err )
649693 require .Equal (t , len (codeGeneratorRequests ), len (requestsFromImages ))
650694 for i := range codeGeneratorRequests {
651695 diff = cmp .Diff (codeGeneratorRequests [i ], requestsFromImages [i ], protocmp .Transform ())
652- require .Equal ( t , "" , diff )
696+ require .Empty ( t , diff )
653697 }
654698 codeGeneratorRequestsIncludeImports := []* pluginpb.CodeGeneratorRequest {
655699 {
@@ -665,6 +709,11 @@ func TestBasic(t *testing.T) {
665709 "import.proto" ,
666710 "a/b.proto" ,
667711 },
712+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
713+ testProtoImageFileToFileDescriptorProto (protoImageFileAA ),
714+ testProtoImageFileToFileDescriptorProto (protoImageFileImport ),
715+ testProtoImageFileToFileDescriptorProto (protoImageFileAB ),
716+ },
668717 },
669718 {
670719 ProtoFile : []* descriptorpb.FileDescriptorProto {
@@ -680,6 +729,10 @@ func TestBasic(t *testing.T) {
680729 "b/a.proto" ,
681730 "b/b.proto" ,
682731 },
732+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
733+ testProtoImageFileToFileDescriptorProto (protoImageFileBA ),
734+ testProtoImageFileToFileDescriptorProto (protoImageFileBB ),
735+ },
683736 },
684737 {
685738 ProtoFile : []* descriptorpb.FileDescriptorProto {
@@ -690,13 +743,17 @@ func TestBasic(t *testing.T) {
690743 FileToGenerate : []string {
691744 "d/d.proto/d.proto" ,
692745 },
746+ SourceFileDescriptors : []* descriptorpb.FileDescriptorProto {
747+ testProtoImageFileToFileDescriptorProto (protoImageFileOutlandishDirectoryName ),
748+ },
693749 },
694750 }
695- requestsFromImages = bufimage .ImagesToCodeGeneratorRequests (imagesByDir , "foo" , nil , true , false )
751+ requestsFromImages , err = bufimage .ImagesToCodeGeneratorRequests (imagesByDir , "foo" , nil , true , false )
752+ require .NoError (t , err )
696753 require .Equal (t , len (codeGeneratorRequestsIncludeImports ), len (requestsFromImages ))
697754 for i := range codeGeneratorRequestsIncludeImports {
698755 diff = cmp .Diff (codeGeneratorRequestsIncludeImports [i ], requestsFromImages [i ], protocmp .Transform ())
699- require .Equal ( t , "" , diff )
756+ require .Empty ( t , diff )
700757 }
701758}
702759
0 commit comments