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

Function Test_stopBackgroundManagers

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

Source from the content-addressed store, hash-verified

4369}
4370
4371func Test_stopBackgroundManagers(t *testing.T) {
4372 db, ctx := setupTestDB(t)
4373 defer db.Close(ctx)
4374
4375 testCases := []struct {
4376 resyncManager *BackgroundManager
4377 tombstoneCompactionManager *BackgroundManager
4378 attachmentCompactionManager *BackgroundManager
4379 expected int
4380 }{
4381 {
4382 expected: 0,
4383 },
4384 {
4385 resyncManager: &BackgroundManager{
4386 name: "test_resync",
4387 Process: &testBackgroundProcess{isStoppable: true},
4388 },
4389 expected: 1,
4390 },
4391 {
4392 resyncManager: &BackgroundManager{
4393 name: "test_resync",
4394 Process: &testBackgroundProcess{isStoppable: true},
4395 },
4396 tombstoneCompactionManager: &BackgroundManager{
4397 name: "test_tombstone",
4398 Process: &testBackgroundProcess{isStoppable: true},
4399 },
4400 attachmentCompactionManager: &BackgroundManager{
4401 name: "test_attachment",
4402 Process: &testBackgroundProcess{isStoppable: true},
4403 },
4404 expected: 3,
4405 },
4406 }
4407
4408 emptyOptions := map[string]interface{}{}
4409
4410 for i, testCase := range testCases {
4411 t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
4412 db.ResyncManager = testCase.resyncManager
4413 db.AttachmentCompactionManager = testCase.attachmentCompactionManager
4414 db.TombstoneCompactionManager = testCase.tombstoneCompactionManager
4415 if db.ResyncManager != nil {
4416 err := db.ResyncManager.Start(ctx, emptyOptions)
4417 assert.NoError(t, err)
4418 }
4419 if db.AttachmentCompactionManager != nil {
4420 err := db.AttachmentCompactionManager.Start(ctx, emptyOptions)
4421 assert.NoError(t, err)
4422 }
4423 if db.TombstoneCompactionManager != nil {
4424 err := db.TombstoneCompactionManager.Start(ctx, emptyOptions)
4425 assert.NoError(t, err)
4426 }
4427
4428 bgManagers := db.stopBackgroundManagers()

Callers

nothing calls this directly

Calls 6

setupTestDBFunction · 0.85
CloseMethod · 0.65
RunMethod · 0.65
StartMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected