(t *testing.T)
| 1102 | } |
| 1103 | |
| 1104 | func 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 | |
| 1137 | func TestImportFeedNonJSONExistingDoc(t *testing.T) { |
| 1138 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyCRUD, base.KeyMigrate, base.KeyImport) |
nothing calls this directly
no test coverage detected