feat(storage): add revision number to documents
Some checks are pending
arcad/edge/pipeline/head Build started...
arcad/edge/pipeline/pr-master Build started...

ref #13
This commit is contained in:
2024-01-11 19:30:30 +01:00
parent a268759d33
commit 8f9428b3f3
8 changed files with 210 additions and 46 deletions

View File

@ -185,8 +185,13 @@ var documentStoreOpsTestCases = []documentStoreOpsTestCase{
return errors.Errorf("upsertedDoc[\"attr1\"]: expected '%v', got '%v'", e, g)
}
upsertedDocRevision, _ := upsertedDoc.Revision()
if e, g := 0, upsertedDocRevision; e != g {
return errors.Errorf("upsertedDoc.Revision(): expected '%v', got '%v'", e, g)
}
// Check that document does not have unexpected properties
if e, g := 4, len(upsertedDoc); e != g {
if e, g := 5, len(upsertedDoc); e != g {
return errors.Errorf("len(upsertedDoc): expected '%v', got '%v'", e, g)
}
@ -217,6 +222,11 @@ var documentStoreOpsTestCases = []documentStoreOpsTestCase{
return errors.New("upsertedDoc2.UpdatedAt() should have been different than upsertedDoc.UpdatedAt()")
}
upsertedDoc2Revision, _ := upsertedDoc2.Revision()
if e, g := 1, upsertedDoc2Revision; e != g {
return errors.Errorf("upsertedDoc.Revision(): expected '%v', got '%v'", e, g)
}
// Verify that there is no additional created document in the collection
results, err := store.Query(ctx, collection, nil)
@ -228,6 +238,11 @@ var documentStoreOpsTestCases = []documentStoreOpsTestCase{
return errors.Errorf("len(results): expected '%v', got '%v'", e, g)
}
firstResultRevision, _ := results[0].Revision()
if e, g := 1, firstResultRevision; e != g {
return errors.Errorf("results[0].Revision(): expected '%v', got '%v'", e, g)
}
return nil
},
},
@ -437,7 +452,6 @@ func testDocumentStoreOps(ctx context.Context, t *testing.T, store storage.Docum
for _, tc := range documentStoreOpsTestCases {
func(tc documentStoreOpsTestCase) {
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
if err := tc.Run(ctx, store); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}