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

Function TestImportFeedNonJSONExistingDoc

db/import_test.go:1137–1175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1135}
1136
1137func TestImportFeedNonJSONExistingDoc(t *testing.T) {
1138 base.SetUpTestLogging(t, base.LevelDebug, base.KeyCRUD, base.KeyMigrate, base.KeyImport)
1139 base.SkipImportTestsIfNotEnabled(t)
1140 bucket := base.GetTestBucket(t)
1141 defer bucket.Close(base.TestCtx(t))
1142
1143 db, ctx := setupTestDBWithOptionsAndImport(t, bucket, DatabaseContextOptions{})
1144 defer db.Close(ctx)
1145
1146 // make sure no documents are imported
1147 require.Equal(t, int64(0), db.DbStats.SharedBucketImport().ImportCount.Value())
1148 require.Equal(t, int64(0), db.DbStats.SharedBucketImport().ImportErrorCount.Value())
1149
1150 // docs named so they will both be on vBucket 1 in both 64 and 1024 vbuckets
1151 const (
1152 doc1 = "bookstand"
1153 doc2 = "chipchop"
1154 )
1155
1156 _, err := bucket.GetSingleDataStore().Add(doc1, 0, []byte(`{"foo": "bar"}`))
1157 require.NoError(t, err)
1158
1159 base.RequireWaitForStat(t, func() int64 {
1160 return db.DbStats.SharedBucketImport().ImportCount.Value()
1161 }, 1)
1162
1163 // logs and increments ImportErrorCount
1164 // [INF] .. col:sg_test_0 Unmarshal error during importDoc json: cannot unmarshal number into Go value of type db.Body
1165 err = bucket.GetSingleDataStore().Set(doc1, 0, nil, []byte(`1`))
1166 require.NoError(t, err)
1167
1168 _, err = bucket.GetSingleDataStore().Add(doc2, 0, []byte(`{"foo" : "bar"}`))
1169 require.NoError(t, err)
1170
1171 base.RequireWaitForStat(t, func() int64 {
1172 return db.DbStats.SharedBucketImport().ImportCount.Value()
1173 }, 2)
1174 require.Equal(t, int64(1), db.DbStats.SharedBucketImport().ImportErrorCount.Value())
1175}
1176
1177func TestMetadataOnlyUpdate(t *testing.T) {
1178

Callers

nothing calls this directly

Calls 13

SetUpTestLoggingFunction · 0.92
GetTestBucketFunction · 0.92
TestCtxFunction · 0.92
RequireWaitForStatFunction · 0.92
SharedBucketImportMethod · 0.80
CloseMethod · 0.65
EqualMethod · 0.45
ValueMethod · 0.45
AddMethod · 0.45
GetSingleDataStoreMethod · 0.45

Tested by

no test coverage detected