Skip to content

Commit 19913b4

Browse files
committed
Add basic test for mongocompat snippet
1 parent 690b3d3 commit 19913b4

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.github/workflows/check-test.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read # we just need to checkout the repo
13+
14+
jobs:
15+
test:
16+
name: Test
17+
18+
timeout-minutes: 45
19+
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest]
23+
node: [20.x, 24.x]
24+
fail-fast: false
25+
26+
runs-on: ${{ matrix.os }}
27+
28+
steps:
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ matrix.node }}
33+
34+
- name: Checkout
35+
uses: actions/checkout@v5
36+
37+
- name: Install Dependencies
38+
run: |
39+
ls -lA ..
40+
npm install
41+
npx lerna bootstrap
42+
shell: bash
43+
44+
- name: Run Tests
45+
run: npm run test -- --stream
46+
shell: bash

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
},
88
"scripts": {
99
"make-index": "node scripts/make-index",
10-
"show-index": "node scripts/show-index"
10+
"show-index": "node scripts/show-index",
11+
"test": "lerna run test"
1112
},
1213
"homepage": "https://github.com/mongodb-labs/mongosh-snippets",
1314
"repository": {
@@ -16,5 +17,8 @@
1617
},
1718
"bugs": {
1819
"url": "https://github.com/mongodb-labs/mongosh-snippets/issues"
20+
},
21+
"overrides": {
22+
"node-gyp": "^11.4.2"
1923
}
2024
}

snippets/mongocompat/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@
88
"license": "SSPL",
99
"publishConfig": {
1010
"access": "public"
11+
},
12+
"scripts": {
13+
"test": "mongosh test.js"
14+
},
15+
"devDependencies": {
16+
"mongosh": "^2.5.8"
1117
}
1218
}

snippets/mongocompat/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
load(__dirname + '/index.js');
2+
3+
assert.strictEqual(ObjectId('0123456789abcdef01234567').tojson(), 'ObjectId("0123456789abcdef01234567")');

0 commit comments

Comments
 (0)