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

Function requireDocumentReadEvents

rest/audit_test.go:1520–1533  ·  view source on GitHub ↗

requireDocumentReadEvents validates that there read events for each doc version specified. There should be only audit events for a given docid and it should be revid specified.

(rt *RestTester, output []byte, docID string, docVersions []string)

Source from the content-addressed store, hash-verified

1518
1519// requireDocumentReadEvents validates that there read events for each doc version specified. There should be only audit events for a given docid and it should be revid specified.
1520func requireDocumentReadEvents(rt *RestTester, output []byte, docID string, docVersions []string) {
1521 events := jsonLines(rt.TB(), output)
1522 var docVersionsFound []string
1523 for _, event := range events {
1524 // skip events that are the target eventID
1525 if base.AuditID(event[base.AuditFieldID].(float64)) != base.AuditIDDocumentRead {
1526 continue
1527 }
1528 require.Equal(rt.TB(), docID, event[base.AuditFieldDocID])
1529 docVersionsFound = append(docVersionsFound, event[base.AuditFieldDocVersion].(string))
1530 }
1531 require.Len(rt.TB(), docVersions, len(docVersionsFound), "expected exactly %d document read events, got %d", len(docVersions), len(docVersionsFound))
1532 require.Equal(rt.TB(), docVersions, docVersionsFound)
1533}
1534
1535// requireAttachmentEvents validates that an attachment CRUD event occurred in the right number only on the correct document.
1536func requireAttachmentEvents(rt *RestTester, eventID base.AuditID, output []byte, docID, docVersionStr string, attachmentName string, count int) {

Callers 1

TestAuditDocumentReadFunction · 0.85

Calls 5

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

Tested by

no test coverage detected