Skip to content

Commit 597f4dc

Browse files
committed
Add basic test for mongocompat snippet
1 parent 690b3d3 commit 597f4dc

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

.github/workflows/check-test.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
check-and-test:
16+
name: Check and Test
17+
18+
timeout-minutes: 45
19+
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest]
23+
fail-fast: false
24+
25+
runs-on: ${{ matrix.os }}
26+
27+
steps:
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 24.x
32+
cache: "npm"
33+
34+
- name: Install Dependencies
35+
run: |
36+
npm ci
37+
npx lerna bootstrap
38+
shell: bash
39+
40+
- name: Run Tests
41+
run: npm run test -- --stream
42+
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)