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

Function TestIncreasingRecentSequences

db/database_test.go:3605–3638  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3603}
3604
3605func TestIncreasingRecentSequences(t *testing.T) {
3606 var db *Database
3607 var enableCallback bool
3608 var body Body
3609 var revid string
3610 var ctx context.Context
3611
3612 writeUpdateCallback := func(key string) {
3613 if enableCallback {
3614 enableCallback = false
3615 // Write a doc
3616 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
3617 _, _, err := collection.PutExistingRevWithBody(ctx, "doc1", body, []string{"2-abc", revid}, true, ExistingVersionWithUpdateToHLV)
3618 assert.NoError(t, err)
3619 }
3620 }
3621
3622 db, ctx = setupTestLeakyDBWithCacheOptions(t, DefaultCacheOptions(), base.LeakyBucketConfig{UpdateCallback: writeUpdateCallback})
3623 defer db.Close(ctx)
3624 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
3625
3626 err := json.Unmarshal([]byte(`{"prop": "value"}`), &body)
3627 assert.NoError(t, err)
3628
3629 // Create a doc
3630 revid, _, err = collection.Put(ctx, "doc1", body)
3631 assert.NoError(t, err)
3632
3633 enableCallback = true
3634 doc, _, err := collection.PutExistingRevWithBody(ctx, "doc1", body, []string{"3-abc", "2-abc", revid}, true, ExistingVersionWithUpdateToHLV)
3635 assert.NoError(t, err)
3636
3637 assert.True(t, sort.IsSorted(base.SortedUint64Slice(doc.SyncData.RecentSequences)))
3638}
3639
3640func TestRepairUnorderedRecentSequences(t *testing.T) {
3641 if base.TestUseXattrs() {

Callers

nothing calls this directly

Calls 8

SortedUint64SliceTypeAlias · 0.92
DefaultCacheOptionsFunction · 0.85
CloseMethod · 0.65
PutMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected