fix(mongo): start replica set

This commit is contained in:
Kalista Payne
2024-11-05 14:56:24 -06:00
parent cce4363319
commit ade793e869

View File

@@ -1,5 +1,5 @@
/* eslint-disable-file */ /* eslint-disable-file */
import { MongoMemoryServer } from 'mongodb-memory-server'; import { MongoMemoryReplSet } from 'mongodb-memory-server';
import { dirname } from 'node:path'; import { dirname } from 'node:path';
import { existsSync, mkdirSync } from 'node:fs'; import { existsSync, mkdirSync } from 'node:fs';
@@ -22,11 +22,24 @@ if (!existsSync(mongoDbPath)) {
// async code in where // async code in where
// This will create an new instance of "MongoMemoryServer" and automatically start it // This will create an new instance of "MongoMemoryServer" and automatically start it
const mongod = await MongoMemoryServer.create({ const mongod = await MongoMemoryReplSet.create({
instance: { replSet: {
port: 27017, count: 3,
dbName: TEST_MODE ? 'habitica-test' : 'habitica-dev',
dbPath: mongoDbPath, dbPath: mongoDbPath,
name: 'rs',
}, },
instanceOpts: [
{
port: 27017,
},
{
port: 27018,
},
{
port: 27019,
},
],
dispose: { dispose: {
cleanup: !BUILD_MODE && !TEST_MODE, cleanup: !BUILD_MODE && !TEST_MODE,
} }