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

Function TestResetRevCache

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

Source from the content-addressed store, hash-verified

1113}
1114
1115func TestResetRevCache(t *testing.T) {
1116 dbcOptions := DatabaseContextOptions{
1117 RevisionCacheOptions: &RevisionCacheOptions{
1118 MaxBytes: 100,
1119 MaxItemCount: 10,
1120 },
1121 }
1122 db, ctx := SetupTestDBWithOptions(t, dbcOptions)
1123 defer db.Close(ctx)
1124 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
1125 cacheStats := db.DbStats.Cache()
1126
1127 // add a doc
1128 docSize, _, _ := createDocAndReturnSizeAndRev(t, ctx, "doc1", collection, Body{"test": "doc"})
1129 assert.Equal(t, int64(docSize), cacheStats.RevisionCacheTotalMemory.Value())
1130 assert.Equal(t, int64(1), cacheStats.RevisionCacheNumItems.Value())
1131
1132 // re create rev cache
1133 db.FlushRevisionCacheForTest()
1134
1135 // assert rev cache is reset as expected
1136 assert.Equal(t, int64(0), cacheStats.RevisionCacheTotalMemory.Value())
1137 assert.Equal(t, int64(0), cacheStats.RevisionCacheNumItems.Value())
1138}
1139
1140func TestBasicOperationsOnCacheWithMemoryStat(t *testing.T) {
1141 testCases := []struct {

Callers

nothing calls this directly

Calls 8

SetupTestDBWithOptionsFunction · 0.85
CacheMethod · 0.80
CloseMethod · 0.65
EqualMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected