forked from testcontainers/testcontainers-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneo4j-container.test.ts
More file actions
executable file
·116 lines (98 loc) · 3.82 KB
/
neo4j-container.test.ts
File metadata and controls
executable file
·116 lines (98 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import neo4j from "neo4j-driver";
import { Neo4jContainer, Neo4jPlugin } from "./neo4j-container";
describe("Neo4jContainer", { timeout: 180_000 }, () => {
// createNode {
it("should create a person node", async () => {
const container = await new Neo4jContainer().start();
const driver = neo4j.driver(
container.getBoltUri(),
neo4j.auth.basic(container.getUsername(), container.getPassword())
);
const session = driver.session();
const personName = "Chris";
const result = await session.run("CREATE (a:Person {name: $name}) RETURN a", { name: personName });
const singleRecord = result.records[0];
const node = singleRecord.get(0);
expect(node.properties.name).toBe(personName);
await session.close();
await driver.close();
await container.stop();
});
// }
// v5DefaultPassword {
it("should connect to neo4j:v5 with default password", async () => {
const container = await new Neo4jContainer("neo4j:5.23.0").start();
const driver = neo4j.driver(
container.getBoltUri(),
neo4j.auth.basic(container.getUsername(), container.getPassword())
);
const session = driver.session();
const personName = "Chris";
const result = await session.run("CREATE (a:Person {name: $name}) RETURN a", { name: personName });
const singleRecord = result.records[0];
const node = singleRecord.get(0);
expect(node.properties.name).toBe(personName);
await session.close();
await driver.close();
await container.stop();
});
// }
// setPassword {
it("should connect with custom password", async () => {
const container = await new Neo4jContainer().withPassword("xyz1234@!").start();
const driver = neo4j.driver(
container.getBoltUri(),
neo4j.auth.basic(container.getUsername(), container.getPassword())
);
const session = driver.session();
const personName = "Chris";
const result = await session.run("CREATE (a:Person {name: $name}) RETURN a", { name: personName });
const singleRecord = result.records[0];
const node = singleRecord.get(0);
expect(node.properties.name).toBe(personName);
await session.close();
await driver.close();
await container.stop();
});
// }
// apoc {
it("should have APOC plugin installed", async () => {
const container = await new Neo4jContainer().withApoc().withStartupTimeout(120_000).start();
const driver = neo4j.driver(
container.getBoltUri(),
neo4j.auth.basic(container.getUsername(), container.getPassword())
);
const session = driver.session();
const result = await session.run("CALL apoc.help('text')");
const singleRecord = result.records[0];
expect(singleRecord.length).toBeGreaterThan(0);
await session.close();
await driver.close();
await container.stop();
});
// }
// pluginsList {
it("should work with plugin list", async () => {
const container = await new Neo4jContainer("neo4j:5.26.5")
.withPlugins([Neo4jPlugin.APOC_EXTENDED, Neo4jPlugin.GRAPH_DATA_SCIENCE])
.withStartupTimeout(120_000)
.start();
const driver = neo4j.driver(
container.getBoltUri(),
neo4j.auth.basic(container.getUsername(), container.getPassword())
);
const session = driver.session();
// Monitor methods are only available in extended Apoc.
const result = await session.run("CALL apoc.monitor.ids()");
expect(result.records[0].get("nodeIds")).toEqual({ high: 0, low: 0 });
// Insert one node.
await session.run("CREATE (a:Person {name: $name}) RETURN a", { name: "Some dude" });
// Monitor result should reflect increase in data.
const result2 = await session.run("CALL apoc.monitor.ids()");
expect(result2.records[0].get("nodeIds")).toEqual({ high: 0, low: 1 });
await session.close();
await driver.close();
await container.stop();
});
// }
});