-
-
Save timorthi/13228a9ec10de4f9bbe486c0c864c7ba to your computer and use it in GitHub Desktop.
LeaseLock Engineering: Mocha Parallel Mode globalFixtures.js example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const dockerCompose = require('docker-compose'); | |
const { getDbConnection } = require('../db_connections'); | |
const PATH_TO_DOCKER_COMPOSE_YML = path.join(__dirname); | |
exports.mochaGlobalSetup = async () => { | |
// Bring up the Postgres container for testing | |
await dockerCompose.upAll({ cwd: PATH_TO_DOCKER_COMPOSE_YML }); | |
// Fetch a DB connection to the Postgres container's leaselock_template database which was pre-configured in the docker-compose.yml | |
const dbConnection = await getDbConnection({ | |
host: 'localhost', | |
port: 5432, | |
database: 'leaselock_template' | |
}); // Returns a knex instance | |
// Run all migrations on the `leaselock_template` database so its schema is up to date | |
await dbConnection.migrate.latest(); | |
} | |
exports.mochaGlobalTeardown = async () => { | |
// Bring down the container once the tests finish running | |
await dockerCompose.down({ cwd: PATH_TO_DOCKER_COMPOSE_YML }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment