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

Function TestImportNullDoc

db/import_test.go:711–731  ·  view source on GitHub ↗

Invokes db.importDoc() with a null document body Reproduces https://github.com/couchbase/sync_gateway/issues/3774

(t *testing.T)

Source from the content-addressed store, hash-verified

709// Invokes db.importDoc() with a null document body
710// Reproduces https://github.com/couchbase/sync_gateway/issues/3774
711func TestImportNullDoc(t *testing.T) {
712 if !base.TestUseXattrs() {
713 t.Skip("This test only works with XATTRS enabled and in integration mode")
714 }
715
716 base.SetUpTestLogging(t, base.LevelInfo, base.KeyImport)
717
718 db, ctx := setupTestDB(t)
719 defer db.Close(ctx)
720
721 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db)
722 key := "TestImportNullDoc"
723 var body Body
724 rawNull := []byte("null")
725 existingDoc := &sgbucket.BucketDocument{Body: rawNull, Cas: 1}
726
727 // Import a null document
728 importedDoc, err := collection.importDoc(ctx, key+"1", body, nil, false, 1, existingDoc, ImportOnDemand)
729 assert.Equal(t, base.ErrEmptyDocument, err)
730 assert.True(t, importedDoc == nil, "Expected no imported doc")
731}
732
733func TestImportNullDocRaw(t *testing.T) {
734 base.SetUpTestLogging(t, base.LevelInfo, base.KeyImport)

Callers

nothing calls this directly

Calls 7

TestUseXattrsFunction · 0.92
SetUpTestLoggingFunction · 0.92
setupTestDBFunction · 0.85
importDocMethod · 0.80
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected