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

Function TestImportFeedNonJSONNewDoc

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

Source from the content-addressed store, hash-verified

1102}
1103
1104func TestImportFeedNonJSONNewDoc(t *testing.T) {
1105 base.SetUpTestLogging(t, base.LevelDebug, base.KeyMigrate, base.KeyImport)
1106 base.SkipImportTestsIfNotEnabled(t)
1107 bucket := base.GetTestBucket(t)
1108 defer bucket.Close(base.TestCtx(t))
1109
1110 db, ctx := setupTestDBWithOptionsAndImport(t, bucket, DatabaseContextOptions{})
1111 defer db.Close(ctx)
1112
1113 // make sure no documents are imported
1114 require.Equal(t, int64(0), db.DbStats.SharedBucketImport().ImportCount.Value())
1115 require.Equal(t, int64(0), db.DbStats.SharedBucketImport().ImportErrorCount.Value())
1116
1117 // docs named so they will both be on vBucket 1 in both 64 and 1024 vbuckets
1118 const (
1119 doc1 = "bookstand"
1120 doc2 = "chipchop"
1121 )
1122
1123 // logs because a JSON number is not a JSON object
1124 // [DBG] .. col:sg_test_0 <ud>bookstand</ud> not able to be imported. Error: Could not unmarshal _sync out of document body: json: cannot unmarshal number into Go value of type db.documentRoot
1125 _, err := bucket.GetSingleDataStore().Add(doc1, 0, []byte(`1`))
1126 require.NoError(t, err)
1127
1128 _, err = bucket.GetSingleDataStore().Add(doc2, 0, []byte(`{"foo" : "bar"}`))
1129 require.NoError(t, err)
1130
1131 base.RequireWaitForStat(t, func() int64 {
1132 return db.DbStats.SharedBucketImport().ImportCount.Value()
1133 }, 1)
1134 require.Equal(t, int64(0), db.DbStats.SharedBucketImport().ImportErrorCount.Value())
1135}
1136
1137func TestImportFeedNonJSONExistingDoc(t *testing.T) {
1138 base.SetUpTestLogging(t, base.LevelDebug, base.KeyCRUD, base.KeyMigrate, base.KeyImport)

Callers

nothing calls this directly

Calls 12

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