(t *testing.T)
| 2303 | } |
| 2304 | |
| 2305 | func TestCorrectHLVWhenFetchingBackupRev(t *testing.T) { |
| 2306 | db, ctx := SetupTestDBWithOptions(t, DatabaseContextOptions{ |
| 2307 | // enable delta sync so CV revs are backed up |
| 2308 | DeltaSyncOptions: DeltaSyncOptions{ |
| 2309 | Enabled: true, |
| 2310 | RevMaxAgeSeconds: DefaultDeltaSyncRevMaxAge, |
| 2311 | }, |
| 2312 | }) |
| 2313 | defer db.Close(ctx) |
| 2314 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 2315 | |
| 2316 | docID := t.Name() |
| 2317 | agent := NewHLVAgent(t, collection.dataStore, "someSourceID", base.VvXattrName) |
| 2318 | |
| 2319 | _ = agent.InsertWithHLV(ctx, docID, nil) |
| 2320 | |
| 2321 | docRev, err := collection.getRev(ctx, docID, "", 0, nil) |
| 2322 | require.NoError(t, err) |
| 2323 | cv := docRev.CV.String() |
| 2324 | |
| 2325 | _, _, err = collection.Put(ctx, docID, Body{"foo": "bar", BodyRev: docRev.RevID}) |
| 2326 | require.NoError(t, err) |
| 2327 | |
| 2328 | // flush cache |
| 2329 | db.FlushRevisionCacheForTest() |
| 2330 | |
| 2331 | // fetch backup rev and assert that the HLV is correct |
| 2332 | _, err = collection.getRev(ctx, docID, docRev.CV.String(), 0, nil) |
| 2333 | require.ErrorContains(t, err, "missing") |
| 2334 | |
| 2335 | // flush cache |
| 2336 | db.FlushRevisionCacheForTest() |
| 2337 | |
| 2338 | // fetch using lower level cache fetch with load from bucket bool true to get the backup rev |
| 2339 | docRev, err = collection.revisionCache.GetWithCV(ctx, docID, docRev.CV, RevCacheOmitDelta, true) |
| 2340 | require.NoError(t, err) |
| 2341 | |
| 2342 | // hlv history should be empty as we are fetching from backup rev |
| 2343 | assert.Empty(t, docRev.HlvHistory) |
| 2344 | assert.Equal(t, cv, docRev.CV.String()) |
| 2345 | } |
| 2346 | |
| 2347 | func TestRemoveFromRevLookup(t *testing.T) { |
| 2348 | cacheHitCounter, cacheMissCounter, cacheNumItems, memoryBytesCounted := base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{} |
nothing calls this directly
no test coverage detected