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

Function TestRevCacheOnDemandImportNoCache

db/revision_cache_test.go:2229–2256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2227}
2228
2229func TestRevCacheOnDemandImportNoCache(t *testing.T) {
2230 base.SkipImportTestsIfNotEnabled(t)
2231
2232 db, ctx := setupTestDB(t)
2233 defer db.Close(ctx)
2234 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
2235
2236 docID := "doc1"
2237 revID1, _, err := collection.Put(ctx, docID, Body{"foo": "bar"})
2238 require.NoError(t, err)
2239
2240 _, exists := collection.revisionCache.Peek(ctx, docID, revID1)
2241 require.True(t, exists)
2242
2243 require.NoError(t, collection.dataStore.Set(docID, 0, nil, []byte(`{"foo": "baz"}`)))
2244
2245 doc, err := collection.GetDocument(ctx, docID, DocUnmarshalSync)
2246 require.NoError(t, err)
2247 require.Equal(t, Body{"foo": "baz"}, doc.Body(ctx))
2248
2249 // rev1 still exists in cache but not on server
2250 _, exists = collection.revisionCache.Peek(ctx, docID, revID1)
2251 require.True(t, exists)
2252
2253 // rev2 is not in cache but is on server
2254 _, exists = collection.revisionCache.Peek(ctx, docID, doc.GetRevTreeID())
2255 require.False(t, exists)
2256}
2257
2258func TestFetchBackupWithDeletedFlag(t *testing.T) {
2259 db, ctx := SetupTestDBWithOptions(t, DatabaseContextOptions{

Callers

nothing calls this directly

Calls 11

setupTestDBFunction · 0.85
CloseMethod · 0.65
PutMethod · 0.65
PeekMethod · 0.65
GetDocumentMethod · 0.65
SetMethod · 0.45
EqualMethod · 0.45
BodyMethod · 0.45
GetRevTreeIDMethod · 0.45

Tested by

no test coverage detected