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

Function TestSetAttachment

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

Source from the content-addressed store, hash-verified

586}
587
588func TestSetAttachment(t *testing.T) {
589 db, ctx := setupTestDB(t)
590 defer db.Close(ctx)
591 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
592
593 // Set attachment with a valid attachment
594 att := `{"att1.txt": {"data": "YXR0MS50eHQ="}}}`
595 key := Sha1DigestKey([]byte(att))
596 err := collection.setAttachment(ctx, key, []byte(att))
597 assert.NoError(t, err, "Attachment should be saved in db and key should be returned")
598 attBytes, err := collection.GetAttachment(key)
599 assert.NoError(t, err, "Attachment should be retrieved from the database")
600 assert.Equal(t, att, string(attBytes))
601}
602
603func TestRetrieveAncestorAttachments(t *testing.T) {
604 db, ctx := setupTestDBAllowConflicts(t)

Callers

nothing calls this directly

Calls 7

setupTestDBFunction · 0.85
Sha1DigestKeyFunction · 0.85
setAttachmentMethod · 0.80
GetAttachmentMethod · 0.80
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected