Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Make integration tests atomic #302

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/apollo-server/movies-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Movie {
imdbRating: Float
ratings: [Rated]
genres: [Genre] @relation(name: "IN_GENRE", direction: "OUT")
similar(first: Int = 3, offset: Int = 0, limit: Int = 5): [Movie] @cypher(statement: "WITH {this} AS this MATCH (this)--(:Genre)--(o:Movie) RETURN o LIMIT {limit}")
similar(first: Int = 3, offset: Int = 0, limit: Int = 5): [Movie] @cypher(statement: "WITH {this} AS this MATCH (this)--(:Genre)--(o:Movie) RETURN o ORDER BY o.title LIMIT {limit}")
mostSimilar: Movie @cypher(statement: "WITH {this} AS this RETURN this")
degree: Int @cypher(statement: "WITH {this} AS this RETURN SIZE((this)--())")
actors(first: Int = 3, offset: Int = 0): [Actor] @relation(name: "ACTED_IN", direction:"IN")
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"test-tck": "nyc ava --fail-fast test/tck/*.test.js",
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"test-all": "nyc ava --verbose",
"test-isolated": "nyc ava test/**/*.test.js --verbose --match='!*not-isolated*'",
"debug": "nodemon ./example/apollo-server/movies.js --exec babel-node --inspect-brk=9229 --nolazy",
"debug-typedefs": "nodemon ./example/apollo-server/movies-typedefs.js --exec babel-node --inspect-brk=9229 --nolazy",
"debug-interface": "nodemon ./example/apollo-server/interfaceError.js --exec babel-node --inspect-brk=9229 --nolazy"
Expand Down
4 changes: 0 additions & 4 deletions scripts/install-neo4j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ if [ ! -d "neo4j/data/databases/graph.db" ]; then
tar -xzf neo4j-$NEO4J_DIST-$NEO4J_VERSION-unix.tar.gz -C neo4j --strip-components 1
neo4j/bin/neo4j-admin set-initial-password letmein
curl -L https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/$APOC_VERSION/apoc-$APOC_VERSION-all.jar > ./neo4j/plugins/apoc-$APOC_VERSION-all.jar
wget https://s3.amazonaws.com/neo4j-sandbox-usecase-datastores/v$DATASTORE_VERSION/recommendations.db.zip
sudo apt-get install unzip
unzip recommendations.db.zip
mv recommendations.db neo4j/data/databases/graph.db
else
echo "Database is already installed, skipping"
fi
3 changes: 3 additions & 0 deletions scripts/start-neo4j.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if [ ! -d "neo4j/data/databases/graph.db" ]; then
exit 1
else
echo "dbms.allow_upgrade=true" >> ./neo4j/conf/neo4j.conf
echo "dbms.security.procedures.unrestricted=apoc.export.*,apoc.import.*" >> ./neo4j/conf/neo4j.conf
echo "apoc.import.file.enabled=true" >> ./neo4j/conf/neo4j.conf
echo "apoc.import.file.use_neo4j_config=false" >> ./neo4j/conf/neo4j.conf
# Set initial and max heap to workaround JVM in docker issues
dbms_memory_heap_initial_size="2048m" dbms_memory_heap_max_size="2048m" ./neo4j/bin/neo4j start
echo "Waiting up to 2 minutes for neo4j bolt port ($BOLT_PORT)"
Expand Down
196,363 changes: 196,363 additions & 0 deletions test/fixtures/seed.graphml

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions test/helpers/integrationTestHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { v1 as neo4j } from 'neo4j-driver';
import path from 'path';

const driver = neo4j.driver(
process.env.NEO4J_URI || 'bolt://localhost:7687',
neo4j.auth.basic(
process.env.NEO4J_USER || 'neo4j',
process.env.NEO4J_PASSWORD || 'letmein'
)
);

export const resetDatabase = async () => {
const seedPath = path.resolve(__dirname, '../fixtures/seed.graphml');
const session = driver.session();
await session.run(`
MATCH (n) WHERE n:Actor OR n:Director OR n:Genre OR n:Movie OR n:OnlyDate OR n:User DETACH DELETE n RETURN count(n);
`);
await session.run(
`
CALL apoc.import.graphml($seedPath, {batchSize: 10000, storeNodeIds: false, readLabels:true});
`,
{ seedPath }
);
session.close(() => driver.close());
};
Loading