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

Function TestAttachmentForRejectedDocument

db/attachment_test.go:258–277  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

256}
257
258func TestAttachmentForRejectedDocument(t *testing.T) {
259 db, ctx := setupTestDB(t)
260 defer db.Close(ctx)
261
262 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
263 collection.ChannelMapper = channels.NewChannelMapper(ctx,
264 `function(doc, oldDoc) {
265 throw({forbidden: "None shall pass!"});
266 }`, db.Options.JavascriptTimeout)
267
268 docBody := `{"_attachments": {"hello.txt": {"data":"aGVsbG8gd29ybGQ="}}}`
269 var body Body
270 require.NoError(t, base.JSONUnmarshal([]byte(docBody), &body))
271 _, _, err := collection.Put(ctx, "doc1", unmarshalBody(t, docBody))
272 require.Error(t, err)
273
274 // Attempt to retrieve the attachment doc
275 _, _, err = db.Bucket.DefaultDataStore().GetRaw(base.AttPrefix + "sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=")
276 require.Error(t, err, "Expected error when attempting to retrieve attachment document after doc is rejected.")
277}
278
279func TestAttachmentRetrievalUsingRevCache(t *testing.T) {
280 db, ctx := setupTestDB(t)

Callers

nothing calls this directly

Calls 10

NewChannelMapperFunction · 0.92
JSONUnmarshalFunction · 0.92
setupTestDBFunction · 0.85
unmarshalBodyFunction · 0.85
CloseMethod · 0.65
PutMethod · 0.65
ErrorMethod · 0.45
GetRawMethod · 0.45
DefaultDataStoreMethod · 0.45

Tested by

no test coverage detected