@friggframework/test 2.0.0--canary.686.20eda6e.0 → 2.0.0--canary.710.9045bbc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mongodb.db.test.js +24 -0
- package/mongodb.js +8 -8
- package/package.json +7 -6
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const net = require('node:net');
|
|
2
|
+
const { TestMongo } = require('./mongodb');
|
|
3
|
+
|
|
4
|
+
// Opt-in DB test (`npm run test:db`): proves the pinned MongoDB binary
|
|
5
|
+
// downloads and starts on the CI image (Ubuntu 24.04 has no OpenSSL 1.1,
|
|
6
|
+
// which the old 5.0.x default needed).
|
|
7
|
+
describe('TestMongo', () => {
|
|
8
|
+
const testMongo = new TestMongo();
|
|
9
|
+
|
|
10
|
+
beforeAll(() => testMongo.start(), 120_000);
|
|
11
|
+
afterAll(() => testMongo.stop());
|
|
12
|
+
|
|
13
|
+
it('starts mongod and exports a reachable MONGO_URI', async () => {
|
|
14
|
+
const { hostname, port } = new URL(process.env.MONGO_URI);
|
|
15
|
+
|
|
16
|
+
await new Promise((resolve, reject) => {
|
|
17
|
+
const socket = net.connect(Number(port), hostname, () => {
|
|
18
|
+
socket.end();
|
|
19
|
+
resolve();
|
|
20
|
+
});
|
|
21
|
+
socket.on('error', reject);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
package/mongodb.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const { MongoMemoryServer } = require('mongodb-memory-server');
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
3
|
+
// Pin the MongoDB binary instead of relying on the library default. The old
|
|
4
|
+
// default (5.0.19) only ships Ubuntu 20.04 builds that link against OpenSSL
|
|
5
|
+
// 1.1 (libcrypto.so.1.1), which Ubuntu 24.04 (GitHub's ubuntu-latest) no
|
|
6
|
+
// longer ships, so the server failed to start in CI. MongoDB 8.0 has native
|
|
7
|
+
// Ubuntu 24.04 builds. MONGOMS_VERSION still overrides this for local use.
|
|
8
|
+
const MONGODB_BINARY_VERSION = process.env.MONGOMS_VERSION || '8.0.17';
|
|
8
9
|
|
|
9
10
|
class TestMongo {
|
|
10
11
|
#mongoServer;
|
|
@@ -12,9 +13,7 @@ class TestMongo {
|
|
|
12
13
|
// Start the in-memory mongo instance and set env variable for the app to use in its connection.
|
|
13
14
|
async start() {
|
|
14
15
|
this.#mongoServer = await MongoMemoryServer.create({
|
|
15
|
-
binary: { version:
|
|
16
|
-
// The library's default, ephemeralForTest, was removed in MongoDB 7.
|
|
17
|
-
instance: { storageEngine: 'wiredTiger' },
|
|
16
|
+
binary: { version: MONGODB_BINARY_VERSION },
|
|
18
17
|
});
|
|
19
18
|
process.env.MONGO_URI = this.#mongoServer.getUri();
|
|
20
19
|
console.log('Started in memory mongo server', process.env.MONGO_URI);
|
|
@@ -29,4 +28,5 @@ class TestMongo {
|
|
|
29
28
|
|
|
30
29
|
module.exports = {
|
|
31
30
|
TestMongo,
|
|
31
|
+
MONGODB_BINARY_VERSION,
|
|
32
32
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/test",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.710.9045bbc.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@babel/eslint-parser": "^7.18.9",
|
|
7
7
|
"eslint": "^8.22.0",
|
|
@@ -11,18 +11,19 @@
|
|
|
11
11
|
"eslint-plugin-no-only-tests": "^3.0.0",
|
|
12
12
|
"eslint-plugin-yaml": "^0.5.0",
|
|
13
13
|
"jest-runner-groups": "^2.2.0",
|
|
14
|
-
"mongodb-memory-server": "^
|
|
14
|
+
"mongodb-memory-server": "^11.3.0",
|
|
15
15
|
"open": "^8.4.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
19
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
18
|
+
"@friggframework/eslint-config": "2.0.0--canary.710.9045bbc.0",
|
|
19
|
+
"@friggframework/prettier-config": "2.0.0--canary.710.9045bbc.0",
|
|
20
20
|
"jest": "^29.7.0",
|
|
21
21
|
"prettier": "^2.7.1"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
|
|
25
|
-
"test": "jest --passWithNoTests # TODO"
|
|
25
|
+
"test": "jest --passWithNoTests --testPathIgnorePatterns '\\.db\\.test\\.js$' # TODO",
|
|
26
|
+
"test:db": "jest --testMatch '**/*.db.test.js'"
|
|
26
27
|
},
|
|
27
28
|
"author": "",
|
|
28
29
|
"license": "MIT",
|
|
@@ -39,5 +40,5 @@
|
|
|
39
40
|
"publishConfig": {
|
|
40
41
|
"access": "public"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "9045bbc0a84c7c07271e8599d1600d58790537a6"
|
|
43
44
|
}
|