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

Function TestAttachmentProcessError

db/attachment_compaction_test.go:649–686  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

647}
648
649func TestAttachmentProcessError(t *testing.T) {
650 if base.UnitTestUrlIsWalrus() {
651 t.Skip("This test only works against Couchbase Server")
652 }
653
654 b := base.GetTestBucket(t).LeakyBucketClone(base.LeakyBucketConfig{
655 SetXattrCallback: func(key string) error {
656 return fmt.Errorf("some error")
657 },
658 })
659 defer b.Close(base.TestCtx(t))
660
661 testDB1, ctx1 := setupTestDBForBucketDefaultCollection(t, b)
662 defer testDB1.Close(ctx1)
663
664 collection, ctx1 := GetSingleDatabaseCollectionWithUser(ctx1, t, testDB1)
665 CreateLegacyAttachmentDoc(t, ctx1, collection, "docID", []byte("{}"), "attKey", []byte("{}"))
666
667 err := testDB1.AttachmentCompactionManager.Start(ctx1, map[string]interface{}{"database": testDB1})
668 assert.NoError(t, err)
669
670 var status AttachmentManagerResponse
671 err = WaitForConditionWithOptions(t, func() bool {
672 rawStatus, err := testDB1.AttachmentCompactionManager.GetStatus(ctx1)
673 assert.NoError(t, err)
674 err = base.JSONUnmarshal(rawStatus, &status)
675 assert.NoError(t, err)
676
677 if status.State == BackgroundProcessStateError {
678 return true
679 }
680
681 return false
682 }, 200, 1000)
683 require.NoError(t, err)
684
685 assert.Equal(t, status.State, BackgroundProcessStateError)
686}
687
688func TestAttachmentDifferentVBUUIDsBetweenPhases(t *testing.T) {
689 if base.UnitTestUrlIsWalrus() {

Callers

nothing calls this directly

Calls 14

UnitTestUrlIsWalrusFunction · 0.92
GetTestBucketFunction · 0.92
TestCtxFunction · 0.92
JSONUnmarshalFunction · 0.92
LeakyBucketCloneMethod · 0.80
ErrorfMethod · 0.80
CloseMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected