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)
| 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. |
| 983 | func 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 | |
| 1004 | func TestCreateLegacyRevDoc(t *testing.T) { |
| 1005 | rt := NewRestTester(t, nil) |
nothing calls this directly
no test coverage detected