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

Function TestCVPopulationOnDocIDChanges

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

Source from the content-addressed store, hash-verified

424}
425
426func TestCVPopulationOnDocIDChanges(t *testing.T) {
427 rtConfig := RestTesterConfig{
428 SyncFn: `function(doc) {channel(doc.channels)}`,
429 }
430 rt := NewRestTester(t, &rtConfig)
431 defer rt.Close()
432 collection, ctx := rt.GetSingleTestDatabaseCollection()
433 bucketUUID := rt.GetDatabase().EncodedSourceID
434 const DocID = "doc1"
435
436 // activate channel cache
437 _ = rt.WaitForChanges(0, "/{{.keyspace}}/_changes", "", true)
438
439 resp := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+DocID, `{"channels": ["ABC"]}`)
440 RequireStatus(t, resp, http.StatusCreated)
441
442 require.NoError(t, collection.WaitForPendingChanges(base.TestCtx(t)))
443
444 changes := rt.WaitForChanges(1, fmt.Sprintf(`/{{.keyspace}}/_changes?version_type=cv&filter=_doc_ids&doc_ids=%s`, DocID), "", true)
445
446 fetchedDoc, _, err := collection.GetDocWithXattrs(ctx, DocID, db.DocUnmarshalCAS)
447 require.NoError(t, err)
448
449 entryCV := db.GetChangeEntryCV(t, &changes.Results[0])
450 assert.Equal(t, "doc1", changes.Results[0].ID)
451 assert.Equal(t, bucketUUID, entryCV.SourceID)
452 assert.Equal(t, fetchedDoc.Cas, entryCV.Value)
453}
454
455// TestChangesVersionType tests the /_changes REST endpoint with different version_type parameters for each possible underlying feed type and HTTP method.
456func TestChangesVersionType(t *testing.T) {

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected