fix test harness for previous commit (fix loading emptypb) Related to https://github.com/golang/open2opaque/issues/18 PiperOrigin-RevId: 799446811 Change-Id: I14dee49f9f615697236e8cc8d8aa2888d546dbfd
diff --git a/internal/fix/fiximports.go b/internal/fix/fiximports.go index 9131c32..63a3096 100644 --- a/internal/fix/fiximports.go +++ b/internal/fix/fiximports.go
@@ -138,7 +138,12 @@ // name and replace it with something more descriptive and more inline with the // respective team style. func (imp *imports) findAvailableName(path string) string { - if !strings.HasSuffix(path, "go_proto") { + // Google-internally, all protobuf generated code packages end in go_proto. + // Externally, we at least recognize the well-known types, + // such that our tests behave the same way internally and externally. + isProtoImport := strings.HasSuffix(path, "go_proto") || + strings.HasPrefix(path, "google.golang.org/protobuf/types/") + if !isProtoImport { // default name for non proto imports, assumed to be available return filepath.Base(path) }
diff --git a/internal/fix/rules_commonload_test.go b/internal/fix/rules_commonload_test.go index 86e4177..2965836 100644 --- a/internal/fix/rules_commonload_test.go +++ b/internal/fix/rules_commonload_test.go
@@ -47,6 +47,7 @@ "google.golang.org/open2opaque/internal/fix/testdata/proto3test_go_proto": true, "google.golang.org/protobuf/proto": true, "google.golang.org/protobuf/types/gofeaturespb": true, + "google.golang.org/protobuf/types/known/emptypb": true, // Imported by .pb.go files: "google.golang.org/protobuf/reflect/protoreflect": true, "google.golang.org/protobuf/runtime/protoimpl": true,