Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move reset-db logic to run at end of test group. #51

Merged
merged 1 commit into from
Jun 24, 2022
Merged
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
14 changes: 8 additions & 6 deletions pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ async function processCommand( type, opts ) {
fs.writeFileSync( `${__dirname}/context.json`, JSON.stringify( context ) );
const configFile = getGroupConfig( group );

// Reset the database if `--reset-db` option is passed.
if ( opts.resetDb ) {
await resetDb();
}

// Start docker containers.
await batchSpawn.spawn(
'docker',
Expand Down Expand Up @@ -177,7 +172,14 @@ async function processCommand( type, opts ) {
}

throw err;
} ).finally( async () => {
// Reset the database if `--reset-db` option is passed.
if ( opts.resetDb ) {
console.log( 'Resetting database state...' );
await resetDb();
}
} );

} catch ( err ) {
console.error( err );
// eslint-disable-next-line no-process-exit
Expand All @@ -203,7 +205,7 @@ function setupCli() {
] );
const resetDbOpt = /** @type {const} */ ( [
'--reset-db',
'Reset the database before running the test. This will destroy all data that is currently in the database.'
'Reset the database after running a test group. This will destroy all data that is currently in the database.'
] );

program
Expand Down