(t *testing.T)
| 1135 | } |
| 1136 | |
| 1137 | func 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 | |
| 1177 | func TestMetadataOnlyUpdate(t *testing.T) { |
| 1178 |
nothing calls this directly
no test coverage detected