MongoDB Transactions (#12335)

* add run-rs to dependencies

* wip: add replica set to api unit github action

* wip: add replica set to api unit github action

* wip: fix gh actions mongodb replica set setting

* usa replica set for integration tests

* add correct mongodb version matrix for integration tests

* use different db connection on gh actions

* Revert "use different db connection on gh actions"

This reverts commit aa8db759d3.

* add example transaction

* add mongo script to package.json

* abstract mongodb utils, connect using hostname on windows

* npm scripts: mongo -> mongo:dev

* add setup script for run-rs on windows

* gh actions: run in test environment

* remove test files

* better error handling, use cross-spawn to avoid issues on windows

* fix lint
This commit is contained in:
Matteo Pagliazzi
2020-07-14 18:55:47 +02:00
committed by GitHub
parent e89ff95a21
commit c93bf3e498
11 changed files with 1432 additions and 864 deletions

View File

@@ -6,6 +6,10 @@ import nconf from 'nconf';
import {
pipe,
} from './taskHelper';
import {
getDevelopmentConnectionUrl,
getDefaultConnectionOptions,
} from '../website/server/libs/mongodb';
// TODO rewrite
@@ -44,7 +48,10 @@ gulp.task('test:nodemon', gulp.series(done => {
}, 'nodemon'));
gulp.task('test:prepare:mongo', cb => {
mongoose.connect(TEST_DB_URI, err => {
const mongooseOptions = getDefaultConnectionOptions();
const connectionUrl = getDevelopmentConnectionUrl(TEST_DB_URI);
mongoose.connect(connectionUrl, mongooseOptions, err => {
if (err) return cb(`Unable to connect to mongo database. Are you sure it's running? \n\n${err}`);
return mongoose.connection.dropDatabase(err2 => {
if (err2) return cb(err2);