(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestChannelCacheMaxSize(t *testing.T) { |
| 27 | db, ctx := setupTestDB(t) |
| 28 | defer db.Close(ctx) |
| 29 | |
| 30 | cache := db.changeCache.getChannelCache() |
| 31 | |
| 32 | collectionID := GetSingleDatabaseCollection(t, db.DatabaseContext).GetCollectionID() |
| 33 | |
| 34 | // Make channels active |
| 35 | _, err := cache.GetChanges(ctx, channels.NewID("TestA", collectionID), getChangesOptionsWithCtxOnly(t)) |
| 36 | require.NoError(t, err) |
| 37 | _, err = cache.GetChanges(ctx, channels.NewID("TestB", collectionID), getChangesOptionsWithCtxOnly(t)) |
| 38 | require.NoError(t, err) |
| 39 | _, err = cache.GetChanges(ctx, channels.NewID("TestC", collectionID), getChangesOptionsWithCtxOnly(t)) |
| 40 | require.NoError(t, err) |
| 41 | _, err = cache.GetChanges(ctx, channels.NewID("TestD", collectionID), getChangesOptionsWithCtxOnly(t)) |
| 42 | require.NoError(t, err) |
| 43 | |
| 44 | // Add some entries to caches, leaving some empty caches |
| 45 | cache.AddToCache(ctx, logEntry(1, "doc1", "1-a", []string{"TestB", "TestC", "TestD"}, collectionID)) |
| 46 | cache.AddToCache(ctx, logEntry(2, "doc2", "1-a", []string{"TestB", "TestC", "TestD"}, collectionID)) |
| 47 | cache.AddToCache(ctx, logEntry(3, "doc3", "1-a", []string{"TestB", "TestC", "TestD"}, collectionID)) |
| 48 | cache.AddToCache(ctx, logEntry(4, "doc4", "1-a", []string{"TestC"}, collectionID)) |
| 49 | |
| 50 | db.UpdateCalculatedStats(ctx) |
| 51 | |
| 52 | maxEntries := db.DbStats.Cache().ChannelCacheMaxEntries.Value() |
| 53 | assert.Equal(t, 4, int(maxEntries)) |
| 54 | } |
| 55 | |
| 56 | // TestChannelCacheCurrentVersion: |
| 57 | // - Makes channel channels active for channels used in test by requesting changes on each channel |
nothing calls this directly
no test coverage detected