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

Function cmpLoggingEntryList

gcp/observability/logging_test.go:43–66  ·  view source on GitHub ↗
(got []*grpcLogEntry, want []*grpcLogEntry)

Source from the content-addressed store, hash-verified

41)
42
43func cmpLoggingEntryList(got []*grpcLogEntry, want []*grpcLogEntry) error {
44 if diff := cmp.Diff(got, want,
45 // For nondeterministic metadata iteration.
46 cmp.Comparer(func(a map[string]string, b map[string]string) bool {
47 if len(a) > len(b) {
48 a, b = b, a
49 }
50 if len(a) == 0 && len(a) != len(b) { // No metadata for one and the other comparator wants metadata.
51 return false
52 }
53 for k, v := range a {
54 if b[k] != v {
55 return false
56 }
57 }
58 return true
59 }),
60 cmpopts.IgnoreFields(grpcLogEntry{}, "CallID", "Peer"),
61 cmpopts.IgnoreFields(address{}, "IPPort", "Type"),
62 cmpopts.IgnoreFields(payload{}, "Timeout")); diff != "" {
63 return fmt.Errorf("got unexpected grpcLogEntry list, diff (-got, +want): %v", diff)
64 }
65 return nil
66}
67
68type fakeLoggingExporter struct {
69 t *testing.T

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected