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

Function TestLoaderMismatchInCV

db/revision_cache_test.go:1914–1933  ·  view source on GitHub ↗

TestLoaderMismatchInCV: - Get doc that is not in cache by CV to trigger a load from bucket - Ensure the CV passed into the GET operation won't match the doc in the bucket - Assert we get error and the value is not loaded into the cache

(t *testing.T)

Source from the content-addressed store, hash-verified

1912// - Ensure the CV passed into the GET operation won't match the doc in the bucket
1913// - Assert we get error and the value is not loaded into the cache
1914func TestLoaderMismatchInCV(t *testing.T) {
1915 cacheHitCounter, cacheMissCounter, cacheNumItems, memoryBytesCounted, getDocumentCounter, getRevisionCounter := base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}
1916 cacheOptions := &RevisionCacheOptions{
1917 MaxItemCount: 10,
1918 MaxBytes: 0,
1919 }
1920 cache := NewLRURevisionCache(cacheOptions, CreateTestSingleBackingStoreMap(&testBackingStore{[]string{"test_doc"}, &getDocumentCounter, &getRevisionCounter}, testCollectionID), &cacheHitCounter, &cacheMissCounter, &cacheNumItems, &memoryBytesCounted)
1921
1922 // create cv with incorrect version to the one stored in backing store
1923 cv := Version{SourceID: "test", Value: 1234}
1924
1925 _, err := cache.GetWithCV(base.TestCtx(t), "doc1", &cv, testCollectionID, RevCacheOmitDelta, false)
1926 require.Error(t, err)
1927 require.Error(t, err, base.ErrNotFound)
1928 assert.Equal(t, int64(0), cacheHitCounter.Value())
1929 assert.Equal(t, int64(1), cacheMissCounter.Value())
1930 assert.Equal(t, 0, cache.lruList.Len())
1931 assert.Equal(t, 0, len(cache.hlvCache))
1932 assert.Equal(t, 0, len(cache.cache))
1933}
1934
1935// TestConcurrentLoadByCVAndRevOnCache:
1936// - Create cache

Callers

nothing calls this directly

Calls 8

GetWithCVMethod · 0.95
TestCtxFunction · 0.92
NewLRURevisionCacheFunction · 0.85
LenMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected