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

Function checkDescriptorResults

reflection/test/serverreflection_test.go:322–344  ·  view source on GitHub ↗
(t *testing.T, descriptors [][]byte, expect []string)

Source from the content-addressed store, hash-verified

320}
321
322func checkDescriptorResults(t *testing.T, descriptors [][]byte, expect []string) {
323 t.Helper()
324 if len(descriptors) != len(expect) {
325 t.Errorf("expected result to contain %d descriptor(s); instead got %d", len(expect), len(descriptors))
326 }
327 names := map[string]struct{}{}
328 for i, desc := range descriptors {
329 var descProto descriptorpb.FileDescriptorProto
330 if err := proto.Unmarshal(desc, &descProto); err != nil {
331 t.Fatalf("could not unmarshal descriptor result #%d", i+1)
332 }
333 names[descProto.GetName()] = struct{}{}
334 }
335 actual := make([]string, 0, len(names))
336 for name := range names {
337 actual = append(actual, name)
338 }
339 sort.Strings(actual)
340 sort.Strings(expect)
341 if !reflect.DeepEqual(actual, expect) {
342 t.Fatalf("expected file descriptors for %v; instead got %v", expect, actual)
343 }
344}
345
346type placeholderFile struct {
347 protoreflect.FileDescriptor

Callers 1

Calls 4

ErrorfMethod · 0.65
UnmarshalMethod · 0.65
FatalfMethod · 0.65
GetNameMethod · 0.45

Tested by

no test coverage detected