Validates InsertPendingEntries timing
(t *testing.T)
| 1667 | |
| 1668 | // Validates InsertPendingEntries timing |
| 1669 | func TestChangeCache_InsertPendingEntries(t *testing.T) { |
| 1670 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyCache, base.KeyChanges) |
| 1671 | |
| 1672 | cacheOptions := DefaultCacheOptions() |
| 1673 | cacheOptions.CachePendingSeqMaxWait = 100 * time.Millisecond |
| 1674 | |
| 1675 | db, ctx := setupTestDBWithCacheOptions(t, cacheOptions) |
| 1676 | defer db.Close(ctx) |
| 1677 | |
| 1678 | // Create a user with access to some channels |
| 1679 | authenticator := db.Authenticator(ctx) |
| 1680 | user, err := authenticator.NewUser("naomi", "letmein", channels.BaseSetOf(t, "ABC", "PBS", "NBC", "TBS")) |
| 1681 | require.NoError(t, err) |
| 1682 | require.NoError(t, authenticator.Save(user)) |
| 1683 | |
| 1684 | collection := GetSingleDatabaseCollection(t, db.DatabaseContext) |
| 1685 | // Simulate seq 3 + 4 being delayed - write 1,2,5,6 |
| 1686 | WriteDirect(t, collection, []string{"ABC", "NBC"}, 1) |
| 1687 | WriteDirect(t, collection, []string{"ABC"}, 2) |
| 1688 | WriteDirect(t, collection, []string{"ABC", "PBS"}, 5) |
| 1689 | WriteDirect(t, collection, []string{"ABC", "PBS"}, 6) |
| 1690 | |
| 1691 | // wait for InsertPendingEntries to fire, move 3 and 4 to skipped and get seqs 5 + 6 |
| 1692 | require.NoError(t, db.changeCache.waitForSequence(ctx, 6, base.DefaultWaitForSequence)) |
| 1693 | |
| 1694 | } |
| 1695 | |
| 1696 | // Generator for processEntry |
| 1697 | type testProcessEntryFeed struct { |
nothing calls this directly
no test coverage detected