MCPcopy
hub / github.com/grpc/grpc-go / TestFileDescWithDependencies

Method TestFileDescWithDependencies

reflection/test/serverreflection_test.go:174–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

172}
173
174func (x) TestFileDescWithDependencies(t *testing.T) {
175 depFile, err := protodesc.NewFile(
176 &descriptorpb.FileDescriptorProto{
177 Name: proto.String("dep.proto"),
178 }, nil,
179 )
180 if err != nil {
181 t.Fatalf("unexpected error: %s", err)
182 }
183
184 deps := &protoregistry.Files{}
185 if err := deps.RegisterFile(depFile); err != nil {
186 t.Fatalf("unexpected error: %s", err)
187 }
188
189 rootFileProto := &descriptorpb.FileDescriptorProto{
190 Name: proto.String("root.proto"),
191 Dependency: []string{
192 "google/protobuf/descriptor.proto",
193 "reflection/grpc_testing/proto2_ext2.proto",
194 "dep.proto",
195 },
196 }
197
198 // dep.proto is in deps; the other imports come from protoregistry.GlobalFiles
199 resolver := &combinedResolver{first: protoregistry.GlobalFiles, second: deps}
200 rootFile, err := protodesc.NewFile(rootFileProto, resolver)
201 if err != nil {
202 t.Fatalf("unexpected error: %s", err)
203 }
204
205 // Create a file hierarchy that contains a placeholder for dep.proto
206 placeholderDep := placeholderFile{depFile}
207 placeholderDeps := &protoregistry.Files{}
208 if err := placeholderDeps.RegisterFile(placeholderDep); err != nil {
209 t.Fatalf("unexpected error: %s", err)
210 }
211 resolver = &combinedResolver{first: protoregistry.GlobalFiles, second: placeholderDeps}
212
213 rootFileHasPlaceholderDep, err := protodesc.NewFile(rootFileProto, resolver)
214 if err != nil {
215 t.Fatalf("unexpected error: %s", err)
216 }
217
218 rootFileIsPlaceholder := placeholderFile{rootFile}
219
220 // Full transitive dependency graph of root.proto includes five files:
221 // - root.proto
222 // - google/protobuf/descriptor.proto
223 // - reflection/grpc_testing/proto2_ext2.proto
224 // - reflection/grpc_testing/proto2.proto
225 // - dep.proto
226
227 for _, test := range []struct {
228 name string
229 sent []string
230 root protoreflect.FileDescriptor
231 expect []string

Callers

nothing calls this directly

Calls 5

NewServerV1Function · 0.92
checkDescriptorResultsFunction · 0.85
StringMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected