Invokes db.importDoc() with a null document body Reproduces https://github.com/couchbase/sync_gateway/issues/3774
(t *testing.T)
| 709 | // Invokes db.importDoc() with a null document body |
| 710 | // Reproduces https://github.com/couchbase/sync_gateway/issues/3774 |
| 711 | func 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 | |
| 733 | func TestImportNullDocRaw(t *testing.T) { |
| 734 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyImport) |
nothing calls this directly
no test coverage detected