Skip to content

Commit 19c3168

Browse files
committed
test(MongoInstance): add test for "checkErrorInLine"
1 parent 287bcb9 commit 19c3168

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,5 +497,25 @@ describe('MongodbInstance', () => {
497497
});
498498
});
499499
});
500+
501+
describe('checkErrorInLine()', () => {
502+
it('should emit "instanceError" when shared libraries fail to load', () => {
503+
// actual line copied from mongod 5.0.3
504+
const line =
505+
'/root/.cache/mongodb-binaries/mongod-x64-ubuntu-5.0.3: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory';
506+
507+
// @ts-expect-error "checkErrorInLine" is protected
508+
mongod.checkErrorInLine(line);
509+
510+
expect(events.size).toEqual(1);
511+
512+
const event = events.get(MongoInstanceEvents.instanceError);
513+
expect(event).toBeInstanceOf(StdoutInstanceError);
514+
assertIsError(event); // has to be used, because there is not typeguard from "expect(variable).toBeInstanceOf"
515+
expect(event.message).toEqual(
516+
'Instance Failed to start because an library file is missing: "libcrypto.so.1.1"'
517+
);
518+
});
519+
});
500520
});
501521
});

0 commit comments

Comments
 (0)