Skip to content

Commit 9f28979

Browse files
committed
Merge branch 'beta'
2 parents 0b65dd1 + b6b01c6 commit 9f28979

File tree

13 files changed

+49
-27
lines changed

13 files changed

+49
-27
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [10.1.3-beta.1](https://github.com/typegoose/mongodb-memory-server/compare/v10.1.2...v10.1.3-beta.1) (2024-12-09)
2+
3+
4+
### Fixes
5+
6+
* **DryMongoBinary::getPath:** always absoluteize System_Binary path ([c0975c3](https://github.com/typegoose/mongodb-memory-server/commit/c0975c32a273c452c7e4353096f48e1addec8460))
7+
* **MongoBinary::getPath:** check that "stdout" actually exists ([613e670](https://github.com/typegoose/mongodb-memory-server/commit/613e6704db78c423afbafc3b88301f6f4ea34d8d)), closes [#742](https://github.com/typegoose/mongodb-memory-server/issues/742) [#issuecomment-2528284865](https://github.com/typegoose/mongodb-memory-server/issues/issuecomment-2528284865)
8+
* **MongoBinary:** dont execute systembinary "--version" cmd if version check is false ([03c8412](https://github.com/typegoose/mongodb-memory-server/commit/03c84129a9a58c9d7325d127eea6fb18b18de461))
9+
110
## [10.1.2](https://github.com/typegoose/mongodb-memory-server/compare/v10.1.1...v10.1.2) (2024-10-11)
211

312

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ or
269269
{
270270
"config": {
271271
"mongodbMemoryServer": {
272-
"debug": "1", // also available case-insensitive values: "on" "yes" "true"
272+
"debug": "1" // also available case-insensitive values: "on" "yes" "true"
273273
}
274274
}
275275
}

docs/guides/enable-debug-mode.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ MONGOMS_DEBUG=1 npm run test
2020
{
2121
"config": {
2222
"mongodbMemoryServer": {
23-
"debug": "1", // also available case-insensitive values: "on" "yes" "true"
23+
"debug": "1" // also available case-insensitive values: "on" "yes" "true"
2424
}
2525
}
2626
}

packages/mongodb-memory-server-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-memory-server-core",
3-
"version": "10.1.2",
3+
"version": "10.1.3-beta.1",
44
"description": "MongoDB Server for testing (core package, without autodownload). The server will allow you to connect your favourite ODM or client library to the MongoDB Server and run parallel integration tests isolated from each other.",
55
"main": "lib/index",
66
"types": "lib/index.d.ts",

packages/mongodb-memory-server-core/src/util/DryMongoBinary.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class DryMongoBinary {
8787
if (!!useOpts.systemBinary) {
8888
log(`locateBinary: env "SYSTEM_BINARY" was provided with value: "${useOpts.systemBinary}"`);
8989

90-
const systemReturn = await this.getSystemPath(useOpts.systemBinary);
90+
const systemReturn = await this.getSystemPath(path.resolve(useOpts.systemBinary));
9191

9292
if (isNullOrUndefined(systemReturn)) {
9393
throw new BinaryNotFoundError(useOpts.systemBinary, ' (systemBinary)');

packages/mongodb-memory-server-core/src/util/MongoBinary.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,20 @@ export class MongoBinary {
8787
if (!!options.systemBinary) {
8888
// this case should actually never be false, because if "SYSTEM_BINARY" is set, "locateBinary" will run "getSystemPath" which tests the path for permissions
8989
if (!isNullOrUndefined(binaryPath)) {
90-
log(`getPath: Spawning binaryPath "${binaryPath}" to get version`);
91-
const spawnOutput = spawnSync(binaryPath, ['--version'])
92-
.stdout.toString()
93-
// this regex is to match the first line of the "mongod --version" output "db version v4.0.25" OR "db version v4.2.19-11-ge2f2736"
94-
.match(/^\s*db\s+version\s+v?(\d+\.\d+\.\d+)(-\d*)?(-[a-zA-Z0-9].*)?\s*$/im);
95-
96-
assertion(
97-
!isNullOrUndefined(spawnOutput),
98-
new Error('Couldnt find an version from system binary output!')
99-
);
100-
10190
// dont warn if the versions dont match if "SYSTEM_BINARY_VERSION_CHECK" is false, but still test the binary if it is available to be executed
10291
if (envToBool(resolveConfig(ResolveConfigVariables.SYSTEM_BINARY_VERSION_CHECK))) {
92+
log(`getPath: Spawning binaryPath "${binaryPath}" to get version`);
93+
const spawnOutput = spawnSync(binaryPath, ['--version'])
94+
// NOTE: "stdout" seemingly can be "undefined", see https://github.com/typegoose/mongodb-memory-server/issues/742#issuecomment-2528284865
95+
.stdout?.toString()
96+
// this regex is to match the first line of the "mongod --version" output "db version v4.0.25" OR "db version v4.2.19-11-ge2f2736"
97+
.match(/^\s*db\s+version\s+v?(\d+\.\d+\.\d+)(-\d*)?(-[a-zA-Z0-9].*)?\s*$/im);
98+
99+
assertion(
100+
!isNullOrUndefined(spawnOutput),
101+
new Error('Couldnt find an version from system binary output!')
102+
);
103+
103104
log('getPath: Checking & Warning about version conflicts');
104105
const binaryVersion = spawnOutput[1];
105106

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinary.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ build environment:
192192
expect(console.warn).toHaveBeenCalledTimes(1);
193193
});
194194

195-
it('should return and check an SYSTEM_BINARY and dont warn version conflict if SYSTEM_BINARY_VERSION_CHECK is false', async () => {
195+
it('should return and check a SYSTEM_BINARY and dont warn version conflict if SYSTEM_BINARY_VERSION_CHECK is false', async () => {
196196
jest.spyOn(console, 'warn');
197197
// Output taken from mongodb x64 for "ubuntu" version "4.0.25"
198198
// DO NOT INDENT THE TEXT
@@ -218,7 +218,7 @@ build environment:
218218
process.env[envName(ResolveConfigVariables.SYSTEM_BINARY_VERSION_CHECK)] = 'false';
219219

220220
const output = await MongoBinary.getPath();
221-
expect(childProcess.spawnSync).toHaveBeenCalledTimes(1);
221+
expect(childProcess.spawnSync).toHaveBeenCalledTimes(0);
222222
expect(MongoBinary.download).not.toHaveBeenCalled();
223223
expect(console.warn).not.toHaveBeenCalled();
224224
expect(output).toBe(sysBinaryPath);

packages/mongodb-memory-server-core/src/util/__tests__/dryBinary.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,18 @@ describe('DryBinary', () => {
499499
expect(fspromises.access).toHaveBeenCalled();
500500
});
501501

502+
it('should return SystemBinary with absolute path', async () => {
503+
const mockBinary = 'bin/mongod';
504+
process.env[envName(ResolveConfigVariables.SYSTEM_BINARY)] = mockBinary;
505+
jest.spyOn(fspromises, 'access').mockResolvedValue(void 0);
506+
507+
const returnValue = await binary.DryMongoBinary.locateBinary({ version: '1.1.1' });
508+
expect(returnValue).not.toEqual(mockBinary);
509+
expect(returnValue).toEqual(path.resolve(mockBinary));
510+
expect(binary.DryMongoBinary.binaryCache.size).toBe(0); // system binaries dont get added to the cache
511+
expect(fspromises.access).toHaveBeenCalled();
512+
});
513+
502514
it('should throw an error if SystemBinary was provided, but not found', async () => {
503515
const mockBinary = '/usr/local/bin/mongod';
504516
process.env[envName(ResolveConfigVariables.SYSTEM_BINARY)] = mockBinary;

packages/mongodb-memory-server-global-4.0/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-memory-server-global-4.0",
3-
"version": "10.1.2",
3+
"version": "10.1.3-beta.1",
44
"mongodb_version": "4.0.28",
55
"description": "MongoDB Server for testing (auto-download 4.0 version to ~/.cache/mongodb-binaries).",
66
"main": "index.js",
@@ -25,7 +25,7 @@
2525
"mongomem"
2626
],
2727
"dependencies": {
28-
"mongodb-memory-server-core": "10.1.2",
28+
"mongodb-memory-server-core": "10.1.3-beta.1",
2929
"tslib": "^2.7.0"
3030
},
3131
"scripts": {

packages/mongodb-memory-server-global-4.2/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-memory-server-global-4.2",
3-
"version": "10.1.2",
3+
"version": "10.1.3-beta.1",
44
"mongodb_version": "4.2.24",
55
"description": "MongoDB Server for testing (auto-download 4.2 version to ~/.cache/mongodb-binaries).",
66
"main": "index.js",
@@ -25,7 +25,7 @@
2525
"mongomem"
2626
],
2727
"dependencies": {
28-
"mongodb-memory-server-core": "10.1.2",
28+
"mongodb-memory-server-core": "10.1.3-beta.1",
2929
"tslib": "^2.7.0"
3030
},
3131
"scripts": {

packages/mongodb-memory-server-global-4.4/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-memory-server-global-4.4",
3-
"version": "10.1.2",
3+
"version": "10.1.3-beta.1",
44
"mongodb_version": "4.4.28",
55
"description": "MongoDB Server for testing (auto-download 4.4 version to ~/.cache/mongodb-binaries).",
66
"main": "index.js",
@@ -25,7 +25,7 @@
2525
"mongomem"
2626
],
2727
"dependencies": {
28-
"mongodb-memory-server-core": "10.1.2",
28+
"mongodb-memory-server-core": "10.1.3-beta.1",
2929
"tslib": "^2.7.0"
3030
},
3131
"scripts": {

packages/mongodb-memory-server-global/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-memory-server-global",
3-
"version": "10.1.2",
3+
"version": "10.1.3-beta.1",
44
"description": "MongoDB Server for testing (auto-download latest version to ~/.cache/mongodb-binaries).",
55
"main": "index.js",
66
"types": "index.d.ts",
@@ -24,7 +24,7 @@
2424
"mongomem"
2525
],
2626
"dependencies": {
27-
"mongodb-memory-server-core": "10.1.2",
27+
"mongodb-memory-server-core": "10.1.3-beta.1",
2828
"tslib": "^2.7.0"
2929
},
3030
"scripts": {

packages/mongodb-memory-server/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-memory-server",
3-
"version": "10.1.2",
3+
"version": "10.1.3-beta.1",
44
"description": "MongoDB Server for testing (auto-download latest version). The server will allow you to connect your favourite ODM or client library to the MongoDB Server and run parallel integration tests isolated from each other.",
55
"main": "index.js",
66
"types": "index.d.ts",
@@ -24,7 +24,7 @@
2424
"mongomem"
2525
],
2626
"dependencies": {
27-
"mongodb-memory-server-core": "10.1.2",
27+
"mongodb-memory-server-core": "10.1.3-beta.1",
2828
"tslib": "^2.7.0"
2929
},
3030
"scripts": {

0 commit comments

Comments
 (0)