MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / requireDocumentEvents

Function requireDocumentEvents

rest/audit_test.go:1553–1566  ·  view source on GitHub ↗

requireDocumentEvents validates that a document CRUD event occurred on the right doc ID with the correct channels.

(rt *RestTester, eventID base.AuditID, output []byte, docID, docVersion string, count int)

Source from the content-addressed store, hash-verified

1551
1552// requireDocumentEvents validates that a document CRUD event occurred on the right doc ID with the correct channels.
1553func requireDocumentEvents(rt *RestTester, eventID base.AuditID, output []byte, docID, docVersion string, count int) {
1554 events := jsonLines(rt.TB(), output)
1555 countFound := 0
1556 for _, event := range events {
1557 // skip events that are the target eventID
1558 if base.AuditID(event[base.AuditFieldID].(float64)) != eventID {
1559 continue
1560 }
1561 require.Equal(rt.TB(), docID, event[base.AuditFieldDocID])
1562 require.Equal(rt.TB(), docVersion, event[base.AuditFieldDocVersion].(string))
1563 countFound++
1564 }
1565 require.Equal(rt.TB(), count, countFound, "expected exactly %d %s events, got %d", count, base.AuditEvents[eventID].Name, countFound)
1566}
1567
1568// requireChangesStartEvent validates that there is a changes start event with the specified fields
1569func requireChangesStartEvent(t testing.TB, output []byte, expectedFields map[string]any) {

Callers 1

Calls 4

AuditIDTypeAlias · 0.92
jsonLinesFunction · 0.85
TBMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected