From 3c4c9c7c85766b120de603c21cf8eb9c2eeebf39 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Tue, 13 Feb 2024 13:52:36 +0100 Subject: [PATCH] Work around graph integrity safeguards in tests --- src/test/16-graphs.ts | 20 ++++++++++++++------ src/test/17-graph-vertices.ts | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/test/16-graphs.ts b/src/test/16-graphs.ts index 39bf2ee4e..d6306e321 100644 --- a/src/test/16-graphs.ts +++ b/src/test/16-graphs.ts @@ -80,20 +80,28 @@ describe("Graph API", function () { describe("graph.create", () => { let edgeCollectionNames: string[]; let vertexCollectionNames: string[]; + let graph: Graph; before(async () => { [vertexCollectionNames, edgeCollectionNames] = await createCollections( db ); }); after(async () => { - await Promise.all( - [...edgeCollectionNames, ...vertexCollectionNames].map((name) => - db.collection(name).drop() - ) - ); + await Promise.all([ + ...edgeCollectionNames.map(async (name) => { + try { + await graph.removeEdgeDefinition(name, true); + } catch {} + }), + ...vertexCollectionNames.map(async (name) => { + try { + await graph.removeVertexCollection(name, true); + } catch {} + }), + ]); }); it("creates the graph", async () => { - const graph = db.graph(`g_${Date.now()}`); + graph = db.graph(`g_${Date.now()}`); await graph.create( edgeCollectionNames.map((name) => ({ collection: name, diff --git a/src/test/17-graph-vertices.ts b/src/test/17-graph-vertices.ts index e1590201b..f8ddcbf91 100644 --- a/src/test/17-graph-vertices.ts +++ b/src/test/17-graph-vertices.ts @@ -96,7 +96,7 @@ describe("Manipulating graph vertices", function () { ); }); afterEach(async () => { - await vertexCollection.drop(); + await graph.removeVertexCollection(vertexCollection.name, true); }); it("adds the given vertex collection to the graph", async () => { const data = await graph.addVertexCollection(vertexCollection.name);