Skip to content

Commit 967e266

Browse files
merceyzaduh95
andauthored
test: store nocks in a sqlite database (#374)
* test: store nocks in a sqlite3 database * chore: remove nock files * refactor: reuse statement * Update tests/recordRequests.js Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> * refactor: only create statements when needed * refactor: move nocks db up one level * fix: close db on exit --------- Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 451dcf8 commit 967e266

File tree

61 files changed

+762
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+762
-603
lines changed

.github/workflows/update-nock-files.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ jobs:
2323
- name: Install Node
2424
uses: actions/setup-node@v4
2525
with:
26-
# Let's use the oldest version supported to be sure the V8
27-
# serialization is compatible with all supported versions.
28-
node-version: 18.x
26+
node-version: lts/*
2927

3028
- name: Get the Yarn cache directory path
3129
id: yarn-cache-dir-path
@@ -43,21 +41,21 @@ jobs:
4341
- run: corepack yarn build # We need the stubs to run the tests
4442

4543
- name: Remove old Nock files to avoid conflicts
46-
run: rm -r tests/nock
44+
run: rm tests/nocks.db
4745

4846
- run: corepack yarn test
4947
env:
5048
NOCK_ENV: record
5149

5250
- name: Check if anything has changed
5351
id: contains-changes
54-
run: echo "result=$(git --no-pager diff --quiet -- tests/nock || echo "yes")" >> $GITHUB_OUTPUT
52+
run: echo "result=$(git --no-pager diff --quiet -- tests/nocks.db || echo "yes")" >> $GITHUB_OUTPUT
5553
shell: bash
5654

5755
- name: Commit changes
5856
if: ${{ steps.contains-changes.outputs.result == 'yes' }}
5957
run: |
60-
git add tests/nock/
58+
git add tests/nocks.db
6159
git config --global user.email "actions@github.com"
6260
git config --global user.name "GitHub Actions"
6361
git commit -m "update Nock files"
@@ -72,10 +70,10 @@ jobs:
7270
env:
7371
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7472

75-
- name: Upload `tests/nock` in case of failure
73+
- name: Upload `tests/nocks.db` in case of failure
7674
uses: actions/upload-artifact@v4
7775
if: ${{ failure() && steps.contains-changes.outputs.result == 'yes' }}
7876
with:
7977
name: nock
8078
path: |
81-
tests/nock
79+
tests/nocks.db

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@yarnpkg/fslib": "^3.0.0-rc.48",
3636
"@zkochan/cmd-shim": "^6.0.0",
3737
"babel-plugin-dynamic-import-node": "^2.3.3",
38+
"better-sqlite3": "^9.4.1",
3839
"clipanion": "^3.0.1",
3940
"debug": "^4.1.1",
4041
"esbuild": "0.19.5",

tests/_runCli.ts

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ export async function runCli(cwd: PortablePath, argv: Array<string>): Promise<{e
66
const err: Array<Buffer> = [];
77

88
return new Promise((resolve, reject) => {
9-
if (process.env.RUN_CLI_ID)
10-
(process.env.RUN_CLI_ID as any)++;
119
const child = spawn(process.execPath, [`--no-warnings`, `-r`, require.resolve(`./recordRequests.js`), require.resolve(`../dist/corepack.js`), ...argv], {
1210
cwd: npath.fromPortablePath(cwd),
1311
env: process.env,

tests/nock/0mijz-lZ_5pF8f6tlAdbKg-1.dat

-1
This file was deleted.

tests/nock/2Vuch5EnmzPEVel1DWYfPQ-1.dat

-1
This file was deleted.

tests/nock/2bh2z3MgoMIcnxHAMev5uQ-1.dat

-1
This file was deleted.

tests/nock/2ituqIIXsQUU5l2SZSMRDQ-1.dat

-1
This file was deleted.

tests/nock/3cCMRJMrFyNpV7MlFGUXYw-1.dat

-1
This file was deleted.

tests/nock/4IfgwoxNR5JV5bBojS26Kg-1.dat

-1
This file was deleted.

tests/nock/4IfgwoxNR5JV5bBojS26Kg-2.dat

-1
This file was deleted.

tests/nock/4IfgwoxNR5JV5bBojS26Kg-3.dat

-1
This file was deleted.

tests/nock/6BSdMkNfyZxTnw4r9rK5ig-1.dat

-1
This file was deleted.

tests/nock/6wKqy4gh7jHaGEejJ6MskQ-1.dat

-1
This file was deleted.

tests/nock/6zkNeK1b_EJchZZ1iQz7GQ-1.dat

-1
This file was deleted.

tests/nock/7_ZKSRHG7OfkRvPJHYpxbQ-1.dat

-1
This file was deleted.
-3.75 MB
Binary file not shown.

tests/nock/AL__3okpCdfjA6kGuG2rFQ-1.dat

-1
This file was deleted.

tests/nock/Bk2ABpjab9iEEgLyTDm7Nw-2.dat

-1
This file was deleted.

tests/nock/ClrKWNyvjynLF4vcKkUjqQ-1.dat

-1
This file was deleted.

tests/nock/D4fdrCUUCl7i1D6eeg49zQ-1.dat

-1
This file was deleted.

tests/nock/GSh7RCQN4e8flEL6h2lnwQ-1.dat

-1
This file was deleted.

tests/nock/K26guRbYG9vZYQwgFU5lHg-1.dat

-1
This file was deleted.

tests/nock/LU_vfrNkPzIhLrr405IpzQ-1.dat

-1
This file was deleted.

tests/nock/M82EVNBXM8yFkn6tOCflMA-1.dat

-1
This file was deleted.

tests/nock/MVR-DPxEL7jQE9aetA791Q-1.dat

-1
This file was deleted.

tests/nock/MuEAzZXT77khPx8FpLSF2A-1.dat

-1
This file was deleted.

tests/nock/S9h20CvrT1ljP2zwMQUMFw-1.dat

-1
This file was deleted.

tests/nock/TnyRFo6IK894n_HQkACElA-1.dat

-1
This file was deleted.

tests/nock/Vp5BnbFIGGY7ZeZMncmwMw-1.dat

-1
This file was deleted.

tests/nock/VtMTrMazyfrMmIBBLfdGzA-1.dat

-1
This file was deleted.

tests/nock/WAsCdU-KCdvkg9dJ46zkWQ-1.dat

-1
This file was deleted.

tests/nock/WyEcK5FmdvhvOqnb2mHi5A-1.dat

-1
This file was deleted.

tests/nock/WyEcK5FmdvhvOqnb2mHi5A-3.dat

-1
This file was deleted.

tests/nock/XtnC4qVqg7VJUOAoKyxAbA-1.dat

-1
This file was deleted.

tests/nock/XtnC4qVqg7VJUOAoKyxAbA-2.dat

-1
This file was deleted.

tests/nock/XtnC4qVqg7VJUOAoKyxAbA-3.dat

-1
This file was deleted.

tests/nock/_2yNDOq6UlHEKY9lwBEOig-1.dat

-1
This file was deleted.

tests/nock/_ssVB5fpNumqL8RMl4TqHw-1.dat

-1
This file was deleted.

0 commit comments

Comments
 (0)