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

Function TestDocIDChangesVersionCVWithLegacyRev

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

Source from the content-addressed store, hash-verified

589}
590
591func TestDocIDChangesVersionCVWithLegacyRev(t *testing.T) {
592 rt := NewRestTester(t, nil)
593 defer rt.Close()
594
595 docID1 := "doc1"
596 docID2 := "doc2"
597 collection, ctx := rt.GetSingleTestDatabaseCollectionWithUser()
598
599 // create doc with legacy revID
600 _, _ = collection.CreateDocNoHLV(t, ctx, docID1, db.Body{"foo": "bar"})
601 // create doc normally, this will have a CV allocated
602 rt.PutDoc(docID2, `{"bar":"foo"}`)
603 rt.WaitForPendingChanges()
604
605 // issue docID changes feed
606 resp := rt.SendAdminRequest(http.MethodGet, fmt.Sprintf(`/{{.keyspace}}/_changes?version_type=cv&filter=_doc_ids&doc_ids=["doc1","doc2"]&include_docs=true`), "")
607 RequireStatus(t, resp, http.StatusOK)
608
609 var changesResults ChangesResults
610 require.NoError(t, base.JSONUnmarshal(resp.Body.Bytes(), &changesResults))
611 require.Len(t, changesResults.Results, 2)
612 for _, changeEntry := range changesResults.Results {
613 require.Len(t, changeEntry.Changes, 1) // ensure only one version type is present
614 for _, change := range changeEntry.Changes {
615 if changeEntry.ID == docID1 {
616 // doc1 was created with a legacy revID, so should have a revID version type
617 _, ok := change[db.ChangesVersionTypeRevTreeID]
618 assert.Truef(t, ok, "Expected version type %s, got %v", db.ChangesVersionTypeRevTreeID, change)
619 } else {
620 // doc2 was created normally so should have a CV version type
621 _, ok := change[db.ChangesVersionTypeCV]
622 assert.Truef(t, ok, "Expected version type %s, got %v", db.ChangesVersionTypeCV, change)
623 }
624 }
625 }
626}
627
628func TestChangesFeedCVWithOldRevOnlyData(t *testing.T) {
629 rt := NewRestTester(t, nil)

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
PutDocMethod · 0.95
WaitForPendingChangesMethod · 0.95
SendAdminRequestMethod · 0.95
JSONUnmarshalFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
LenMethod · 0.65
CreateDocNoHLVMethod · 0.45

Tested by

no test coverage detected