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

Function TestCVPopulationOnChangesViaAPI

rest/changes_test.go:397–424  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func 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
426func TestCVPopulationOnDocIDChanges(t *testing.T) {
427 rtConfig := RestTesterConfig{

Callers

nothing calls this directly

Calls 12

CloseMethod · 0.95
GetDatabaseMethod · 0.95
WaitForChangesMethod · 0.95
SendAdminRequestMethod · 0.95
GetChangeEntryCVFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
GetDocWithXattrsMethod · 0.80
ContextMethod · 0.65
WaitForPendingChangesMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected