|
@@ -9,20 +9,17 @@ import {
|
|
|
EdgeUpdate,
|
|
|
} from "./micro_op";
|
|
|
|
|
|
-let nextId = 0;
|
|
|
-function getId(): UUID {
|
|
|
- return new UUID(nextId++);
|
|
|
-}
|
|
|
+import {
|
|
|
+ getUuidCallback,
|
|
|
+ assert,
|
|
|
+} from "./test_helpers";
|
|
|
|
|
|
-function assert(expression: boolean, msg: string) {
|
|
|
- if (!expression) {
|
|
|
- throw new Error(msg);
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
describe("Delta", () => {
|
|
|
|
|
|
it("Delete/delete node conflict", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const creation = new NodeCreation(getId());
|
|
|
assert(creation.getConflicts().length === 0, "did not expect node creation to be conflicting with any other operation");
|
|
|
|
|
@@ -35,6 +32,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Create/create edge conflict", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const target1Creation = new NodeCreation(getId());
|
|
|
const target2Creation = new NodeCreation(getId());
|
|
@@ -48,6 +47,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Update/update edge conflict", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
|
const newTarget1Creation = new NodeCreation(getId());
|
|
@@ -64,6 +65,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Delete/require (edge source) conflict", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
|
|
|
@@ -76,6 +79,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Delete/require (edge source) conflict (2)", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
// same as before, but now the 'order' of edgeCreation and sourceDeletion is reversed.
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
@@ -89,6 +94,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Require (edge source), then delete (no conflict)", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
// proper way of deleting the source of an edge: the deletion must depend on the edgeCreation
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
@@ -100,6 +107,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Delete/require (edge source) conflict (3)", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
// Same as (2), really, because the additional EdgeUpdate doesn't change anything.
|
|
|
// Only the earliest conflict, between edgeCreation and sourceDeletion, matters.
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
@@ -117,6 +126,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Update edge after deletion of source node (= update/update) conflict", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
// create edge between 2 nodes, and then properly delete the source node
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
@@ -132,6 +143,8 @@ describe("Delta", () => {
|
|
|
});
|
|
|
|
|
|
it("Delete/require (edge target) conflict", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
|
|
|
@@ -143,6 +156,8 @@ describe("Delta", () => {
|
|
|
})
|
|
|
|
|
|
it("Delete/require (edge target) conflict (2)", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
|
const edgeCreation = new EdgeCreation(sourceCreation, "label", targetCreation);
|
|
@@ -155,6 +170,8 @@ describe("Delta", () => {
|
|
|
})
|
|
|
|
|
|
it("Require (edge target), then delete (no conflict)", () => {
|
|
|
+ const getId = getUuidCallback();
|
|
|
+
|
|
|
const sourceCreation = new NodeCreation(getId());
|
|
|
const targetCreation = new NodeCreation(getId());
|
|
|
const edgeCreation = new EdgeCreation(sourceCreation, "label", targetCreation);
|