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

Function rawDocWithAttachmentAndSyncMeta

rest/attachment_test.go:2714–2749  ·  view source on GitHub ↗

rawDocWithAttachmentAndSyncMeta returns a raw document with an attachment and sync metadata inline. RestTester is used to determine the sequence for the document.

(rt *RestTester)

Source from the content-addressed store, hash-verified

2712
2713// rawDocWithAttachmentAndSyncMeta returns a raw document with an attachment and sync metadata inline. RestTester is used to determine the sequence for the document.
2714func rawDocWithAttachmentAndSyncMeta(rt *RestTester) []byte {
2715 latestSeq, err := rt.GetDatabase().NextSequence(rt.Context())
2716 require.NoError(rt.TB(), err)
2717 return []byte(fmt.Sprintf(`{
2718 "_sync": {
2719 "rev": "1-5fc93bd36377008f96fdae2719c174ed",
2720 "sequence": %d,
2721 "recent_sequences": [
2722 %d
2723 ],
2724 "history": {
2725 "revs": [
2726 "1-5fc93bd36377008f96fdae2719c174ed"
2727 ],
2728 "parents": [
2729 -1
2730 ],
2731 "channels": [
2732 null
2733 ]
2734 },
2735 "cas": "",
2736 "attachments": {
2737 "hi.txt": {
2738 "revpos": 1,
2739 "content_type": "text/plain",
2740 "length": 2,
2741 "stub": true,
2742 "digest": "sha1-witfkXg0JglCjW9RssWvTAveakI="
2743 }
2744 },
2745 "time_saved": "2021-09-01T17:33:03.054227821Z"
2746 },
2747 "key": "value"
2748}`, latestSeq, latestSeq))
2749}
2750
2751// attachmentHeaders returns the headers needed to store an attachment.
2752func attachmentHeaders() map[string]string {

Calls 4

NextSequenceMethod · 0.80
ContextMethod · 0.65
TBMethod · 0.65
GetDatabaseMethod · 0.45

Tested by

no test coverage detected