TestPutDocUpdateVersionVector: - Put a doc and assert that the versions and the source for the hlv is correctly updated - Update that doc and assert HLV has also been updated - Delete the doc and assert that the HLV has been updated in deletion event
(t *testing.T)
| 3051 | // - Update that doc and assert HLV has also been updated |
| 3052 | // - Delete the doc and assert that the HLV has been updated in deletion event |
| 3053 | func TestPutDocUpdateVersionVector(t *testing.T) { |
| 3054 | rt := NewRestTester(t, nil) |
| 3055 | defer rt.Close() |
| 3056 | |
| 3057 | bucketUUID := rt.GetDatabase().EncodedSourceID |
| 3058 | |
| 3059 | resp := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/doc1", `{"key": "value"}`) |
| 3060 | RequireStatus(t, resp, http.StatusCreated) |
| 3061 | |
| 3062 | collection, _ := rt.GetSingleTestDatabaseCollection() |
| 3063 | doc, err := collection.GetDocument(base.TestCtx(t), "doc1", db.DocUnmarshalSync) |
| 3064 | assert.NoError(t, err) |
| 3065 | |
| 3066 | assert.Equal(t, bucketUUID, doc.HLV.SourceID) |
| 3067 | assert.Equal(t, base.HexCasToUint64(doc.SyncData.Cas), doc.HLV.Version) |
| 3068 | assert.Equal(t, base.HexCasToUint64(doc.SyncData.Cas), doc.HLV.CurrentVersionCAS) |
| 3069 | |
| 3070 | // Put a new revision of this doc and assert that the version vector SourceID and Version is updated |
| 3071 | resp = rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/doc1?rev="+doc.SyncData.GetRevTreeID(), `{"key1": "value1"}`) |
| 3072 | RequireStatus(t, resp, http.StatusCreated) |
| 3073 | |
| 3074 | doc, err = collection.GetDocument(base.TestCtx(t), "doc1", db.DocUnmarshalSync) |
| 3075 | assert.NoError(t, err) |
| 3076 | |
| 3077 | assert.Equal(t, bucketUUID, doc.HLV.SourceID) |
| 3078 | assert.Equal(t, base.HexCasToUint64(doc.SyncData.Cas), doc.HLV.Version) |
| 3079 | assert.Equal(t, base.HexCasToUint64(doc.SyncData.Cas), doc.HLV.CurrentVersionCAS) |
| 3080 | |
| 3081 | // Delete doc and assert that the version vector SourceID and Version is updated |
| 3082 | resp = rt.SendAdminRequest(http.MethodDelete, "/{{.keyspace}}/doc1?rev="+doc.SyncData.GetRevTreeID(), "") |
| 3083 | RequireStatus(t, resp, http.StatusOK) |
| 3084 | |
| 3085 | doc, err = collection.GetDocument(base.TestCtx(t), "doc1", db.DocUnmarshalSync) |
| 3086 | assert.NoError(t, err) |
| 3087 | |
| 3088 | assert.Equal(t, bucketUUID, doc.HLV.SourceID) |
| 3089 | assert.Equal(t, base.HexCasToUint64(doc.SyncData.Cas), doc.HLV.Version) |
| 3090 | assert.Equal(t, base.HexCasToUint64(doc.SyncData.Cas), doc.HLV.CurrentVersionCAS) |
| 3091 | } |
| 3092 | |
| 3093 | // TestHLVOnPutWithImportRejection: |
| 3094 | // - Put a doc successfully and assert the HLV is updated correctly |
nothing calls this directly
no test coverage detected