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

Function TestBulkDocsLegacyRevNoop

rest/api_test.go:983–1002  ·  view source on GitHub ↗

TestBulkDocsLegacyRevNoop verifies that POSTing /_bulk_docs with an existing legacy RevTree ID is a no-op and that CV is not set on the response.

(t *testing.T)

Source from the content-addressed store, hash-verified

981
982// TestBulkDocsLegacyRevNoop verifies that POSTing /_bulk_docs with an existing legacy RevTree ID is a no-op and that CV is not set on the response.
983func TestBulkDocsLegacyRevNoop(t *testing.T) {
984 rt := NewRestTester(t, nil)
985 defer rt.Close()
986
987 // create legacy rev (without CV)
988 dbc, ctx := rt.GetSingleTestDatabaseCollectionWithUser()
989 revId, _ := dbc.CreateDocNoHLV(t, ctx, "legacydoc", db.Body{"foo": "bar"})
990 revIDGen, revIDDigest := db.ParseRevID(ctx, revId)
991
992 // now POST it back to _bulk_docs - should be a no-op
993 input := fmt.Sprintf(`{"new_edits":false,"docs": [{"_id": "legacydoc", "_rev": "%s", "_revisions":{"start": %d, "ids":["%s"]}, "foo": "bar"}]}`, revId, revIDGen, revIDDigest)
994 response := rt.SendAdminRequest(http.MethodPost, "/{{.keyspace}}/_bulk_docs", input)
995 RequireStatus(t, response, http.StatusCreated)
996 var docs []any
997 require.NoError(t, base.JSONUnmarshal(response.Body.Bytes(), &docs))
998 assert.Equal(t, []any{
999 // no CV present since we didn't actually update the doc
1000 map[string]any{"rev": revId, "id": "legacydoc"},
1001 }, docs)
1002}
1003
1004func TestCreateLegacyRevDoc(t *testing.T) {
1005 rt := NewRestTester(t, nil)

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
SendAdminRequestMethod · 0.95
ParseRevIDFunction · 0.92
JSONUnmarshalFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
CreateDocNoHLVMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected