(t *testing.T)
| 395 | } |
| 396 | |
| 397 | func TestCVPopulationOnChangesViaAPI(t *testing.T) { |
| 398 | rtConfig := RestTesterConfig{ |
| 399 | SyncFn: `function(doc) {channel(doc.channels)}`, |
| 400 | } |
| 401 | rt := NewRestTester(t, &rtConfig) |
| 402 | defer rt.Close() |
| 403 | collection, ctx := rt.GetSingleTestDatabaseCollection() |
| 404 | bucketUUID := rt.GetDatabase().EncodedSourceID |
| 405 | const DocID = "doc1" |
| 406 | |
| 407 | // activate channel cache |
| 408 | _ = rt.WaitForChanges(0, "/{{.keyspace}}/_changes", "", true) |
| 409 | |
| 410 | resp := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+DocID, `{"channels": ["ABC"]}`) |
| 411 | RequireStatus(t, resp, http.StatusCreated) |
| 412 | |
| 413 | require.NoError(t, collection.WaitForPendingChanges(t.Context())) |
| 414 | |
| 415 | changes := rt.WaitForChanges(1, "/{{.keyspace}}/_changes?version_type=cv", "", true) |
| 416 | |
| 417 | fetchedDoc, _, err := collection.GetDocWithXattrs(ctx, DocID, db.DocUnmarshalCAS) |
| 418 | require.NoError(t, err) |
| 419 | |
| 420 | entryCV := db.GetChangeEntryCV(t, &changes.Results[0]) |
| 421 | assert.Equal(t, "doc1", changes.Results[0].ID) |
| 422 | assert.Equal(t, bucketUUID, entryCV.SourceID) |
| 423 | assert.Equal(t, fetchedDoc.Cas, entryCV.Value) |
| 424 | } |
| 425 | |
| 426 | func TestCVPopulationOnDocIDChanges(t *testing.T) { |
| 427 | rtConfig := RestTesterConfig{ |
nothing calls this directly
no test coverage detected