Regression test for CBG-2058.
(t *testing.T)
| 4198 | |
| 4199 | // Regression test for CBG-2058. |
| 4200 | func TestImportCompactPanic(t *testing.T) { |
| 4201 | if !base.TestUseXattrs() { |
| 4202 | t.Skip("requires xattrs") |
| 4203 | } |
| 4204 | |
| 4205 | // Set the compaction and purge interval unrealistically low to reproduce faster |
| 4206 | db, ctx := setupTestDBWithOptionsAndImport(t, nil, DatabaseContextOptions{ |
| 4207 | CompactInterval: 1, |
| 4208 | TestPurgeIntervalOverride: base.Ptr(time.Duration(0)), |
| 4209 | }) |
| 4210 | defer db.Close(ctx) |
| 4211 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 4212 | |
| 4213 | // Create a document, then delete it, to create a tombstone |
| 4214 | rev, doc, err := collection.Put(ctx, "test", Body{}) |
| 4215 | require.NoError(t, err) |
| 4216 | _, _, err = collection.DeleteDoc(ctx, doc.ID, DocVersion{RevTreeID: rev}) |
| 4217 | require.NoError(t, err) |
| 4218 | require.NoError(t, collection.WaitForPendingChanges(ctx)) |
| 4219 | |
| 4220 | // Wait for Compact to run - in the failing case it'll panic before incrementing the stat |
| 4221 | base.RequireWaitForStat(t, func() int64 { |
| 4222 | return db.DbStats.Database().NumTombstonesCompacted.Value() |
| 4223 | }, 1) |
| 4224 | } |
| 4225 | |
| 4226 | func TestGetDatabaseCollectionWithUserScopesNil(t *testing.T) { |
| 4227 | testCases := []struct { |
nothing calls this directly
no test coverage detected