Skip to content

Commit

Permalink
ignore conflicts in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ktr0731 committed Apr 24, 2022
1 parent 7d8c6c2 commit 6d4887d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func TestMain(m *testing.M) {
cleanup2 := setEnv("XDG_CACHE_HOME", cacheDir)
defer cleanup2()

// TODO: Make registered types to be independent instead of ignoring conflicts.
// Need to make grpc-status-details-bin decoding to be used a passed registry.
cleanup3 := setEnv("GOLANG_PROTOBUF_REGISTRATION_CONFLICT", "ignore")
defer cleanup3()

goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("github.com/desertbit/timer.timerRoutine"))
}

Expand Down
8 changes: 7 additions & 1 deletion idl/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,17 @@ func newSpec(fds []*desc.FileDescriptor) (idl.Spec, error) {
rpcDescs[fqsn] = append(rpcDescs[fqsn], svc.GetMethods()...)
}

prfd, err := protodesc.NewFile(f.AsFileDescriptorProto(), nil)
prfd, err := protodesc.NewFile(f.AsFileDescriptorProto(), protoregistry.GlobalFiles)
if err != nil {
return nil, errors.Wrapf(err, "failed to new protodesc")
}

if _, err := protoregistry.GlobalFiles.FindFileByPath(prfd.Path()); errors.Is(err, protoregistry.NotFound) {
if err := protoregistry.GlobalFiles.RegisterFile(prfd); err != nil {
return nil, err
}
}

for i := 0; i < prfd.Messages().Len(); i++ {
md := prfd.Messages().Get(i)
if _, err := protoregistry.GlobalTypes.FindMessageByName(md.FullName()); !errors.Is(err, protoregistry.NotFound) {
Expand Down

0 comments on commit 6d4887d

Please sign in to comment.