MCPcopy
hub / github.com/PeerDB-io/peerdb / CheckQRecordEquality

Function CheckQRecordEquality

flow/e2eshared/e2eshared.go:81–107  ·  view source on GitHub ↗

checks if two QRecords are identical

(t *testing.T, q []types.QValue, other []types.QValue)

Source from the content-addressed store, hash-verified

79
80// checks if two QRecords are identical
81func CheckQRecordEquality(t *testing.T, q []types.QValue, other []types.QValue) bool {
82 t.Helper()
83
84 if len(q) != len(other) {
85 t.Logf("unequal entry count: %d != %d", len(q), len(other))
86 return false
87 }
88
89 maybeTruncate := func(v types.QValue) string {
90 s := fmt.Sprintf("%+v", v)
91 // truncate log for extremely large documents
92 if len(s) > 1_000_000 {
93 return s[:100] + "...[truncated]"
94 }
95 return s
96 }
97
98 for i, entry := range q {
99 otherEntry := other[i]
100 if !qvalue.Equals(entry, otherEntry) {
101 t.Logf("entry %d: %T %+v != %T %+v", i, entry, maybeTruncate(entry), otherEntry, maybeTruncate(otherEntry))
102 return false
103 }
104 }
105
106 return true
107}
108
109// Equals checks if two QRecordBatches are identical.
110func CheckEqualRecordBatches(t *testing.T, q *model.QRecordBatch, other *model.QRecordBatch) bool {

Callers 2

CheckEqualRecordBatchesFunction · 0.85

Calls 1

EqualsMethod · 0.80

Tested by 1