Skip to content

Commit 903cc00

Browse files
authored
Reachability e2e tests (#968)
* use proper tmp directory in fix e2e tests * rename fixture to simple-npm * create e2e tests for the socket scan reach and socket scan reach --reach-exclude-paths commands * e2e test --reach-ecosystems * add requirements.txt fixture * assert correct recahability structure in one of the e2e tests * fix lint issues * add reachability e2e tests to test the --cwd option and target argument * upgrade @coana-tech/cli to v14.12.117 * fix typo * ignore all fixtures * upgrade coana to version 14.12.118 * increase e2e test timeout
1 parent da83fa1 commit 903cc00

File tree

18 files changed

+4156
-43
lines changed

18 files changed

+4156
-43
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Tests
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, v1.x]
66
tags: ['*']
77
pull_request:
8-
branches: [main]
8+
branches: [main, v1.x]
99
workflow_dispatch:
1010

1111
permissions:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6+
## [1.1.44](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.43) - 2025-12-09
7+
8+
### Changed
9+
- Updated the Coana CLI to v `14.12.118`.
610

711
## [1.1.43](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.43) - 2025-12-08
812

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket",
3-
"version": "1.1.43",
3+
"version": "1.1.44",
44
"description": "CLI for Socket.dev",
55
"homepage": "https://github.com/SocketDev/socket-cli",
66
"license": "MIT AND OFL-1.1",
@@ -94,7 +94,7 @@
9494
"@babel/preset-typescript": "7.27.1",
9595
"@babel/runtime": "7.28.4",
9696
"@biomejs/biome": "2.2.4",
97-
"@coana-tech/cli": "14.12.113",
97+
"@coana-tech/cli": "14.12.118",
9898
"@cyclonedx/cdxgen": "11.11.0",
9999
"@dotenvx/dotenvx": "1.49.0",
100100
"@eslint/compat": "1.3.2",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

socket.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 2
22

33
projectIgnorePaths:
4-
- "test/fixtures/commands/fix"
4+
- "test/fixtures/"

src/commands/fix/cmd-fix.e2e.test.mts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { randomUUID } from 'node:crypto'
12
import { existsSync, promises as fs } from 'node:fs'
3+
import { tmpdir } from 'node:os'
24
import path from 'node:path'
35

46
import { describe, expect } from 'vitest'
@@ -9,6 +11,7 @@ import { cmdit, spawnSocketCli, testPath } from '../../../test/utils.mts'
911
import constants, { FLAG_ID } from '../../constants.mts'
1012

1113
const fixtureBaseDir = path.join(testPath, 'fixtures/commands/fix')
14+
const systemTmpDir = tmpdir()
1215

1316
/**
1417
* Get environment variables for E2E test subprocess.
@@ -30,24 +33,29 @@ function getTestEnv(apiToken: string): Record<string, string | undefined> {
3033
/**
3134
* Create a temporary copy of a fixture directory for testing.
3235
* This allows tests to modify the fixture without affecting the original.
36+
* Uses system temp directory with a unique identifier.
3337
*/
3438
async function createTempFixtureCopy(
3539
fixtureName: string,
36-
): Promise<{ path: string; cleanup: () => Promise<void> }> {
40+
): Promise<{ cleanup: () => Promise<void>; path: string }> {
3741
const sourceDir = path.join(fixtureBaseDir, fixtureName)
38-
const tempDir = path.join(fixtureBaseDir, `${fixtureName}-temp-${Date.now()}`)
42+
const uniqueId = randomUUID()
43+
const tempDir = path.join(
44+
systemTmpDir,
45+
`socket-cli-e2e-${fixtureName}-${uniqueId}`,
46+
)
3947

4048
await fs.cp(sourceDir, tempDir, { recursive: true })
4149

4250
return {
43-
path: tempDir,
4451
cleanup: async () => {
4552
try {
4653
await fs.rm(tempDir, { force: true, recursive: true })
4754
} catch (e) {
4855
logger.warn(`Failed to clean up temp dir ${tempDir}:`, e)
4956
}
5057
},
58+
path: tempDir,
5159
}
5260
}
5361

src/commands/scan/cmd-scan-create.test.mts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ describe('socket scan create', async () => {
306306
'create',
307307
FLAG_ORG,
308308
'fakeOrg',
309-
'test/fixtures/commands/scan/reach',
309+
'test/fixtures/commands/scan/simple-npm',
310310
FLAG_DRY_RUN,
311311
'--repo',
312312
'xyz',
@@ -371,7 +371,7 @@ describe('socket scan create', async () => {
371371
'create',
372372
FLAG_ORG,
373373
'fakeOrg',
374-
'test/fixtures/commands/scan/reach',
374+
'test/fixtures/commands/scan/simple-npm',
375375
FLAG_DRY_RUN,
376376
'--repo',
377377
'xyz',
@@ -406,7 +406,7 @@ describe('socket scan create', async () => {
406406
'create',
407407
FLAG_ORG,
408408
'fakeOrg',
409-
'test/fixtures/commands/scan/reach',
409+
'test/fixtures/commands/scan/simple-npm',
410410
FLAG_DRY_RUN,
411411
'--repo',
412412
'xyz',
@@ -435,7 +435,7 @@ describe('socket scan create', async () => {
435435
'create',
436436
FLAG_ORG,
437437
'fakeOrg',
438-
'test/fixtures/commands/scan/reach',
438+
'test/fixtures/commands/scan/simple-npm',
439439
FLAG_DRY_RUN,
440440
'--repo',
441441
'xyz',
@@ -528,7 +528,7 @@ describe('socket scan create', async () => {
528528
'create',
529529
FLAG_ORG,
530530
'fakeOrg',
531-
'test/fixtures/commands/scan/reach',
531+
'test/fixtures/commands/scan/simple-npm',
532532
FLAG_DRY_RUN,
533533
'--repo',
534534
'xyz',
@@ -596,7 +596,7 @@ describe('socket scan create', async () => {
596596
'create',
597597
FLAG_ORG,
598598
'fakeOrg',
599-
'test/fixtures/commands/scan/reach',
599+
'test/fixtures/commands/scan/simple-npm',
600600
FLAG_DRY_RUN,
601601
'--repo',
602602
'xyz',
@@ -622,7 +622,7 @@ describe('socket scan create', async () => {
622622
'create',
623623
FLAG_ORG,
624624
'fakeOrg',
625-
'test/fixtures/commands/scan/reach',
625+
'test/fixtures/commands/scan/simple-npm',
626626
FLAG_DRY_RUN,
627627
'--repo',
628628
'xyz',
@@ -648,7 +648,7 @@ describe('socket scan create', async () => {
648648
'create',
649649
FLAG_ORG,
650650
'fakeOrg',
651-
'test/fixtures/commands/scan/reach',
651+
'test/fixtures/commands/scan/simple-npm',
652652
FLAG_DRY_RUN,
653653
'--repo',
654654
'xyz',
@@ -678,7 +678,7 @@ describe('socket scan create', async () => {
678678
'create',
679679
FLAG_ORG,
680680
'fakeOrg',
681-
'test/fixtures/commands/scan/reach',
681+
'test/fixtures/commands/scan/simple-npm',
682682
FLAG_DRY_RUN,
683683
'--repo',
684684
'xyz',
@@ -711,7 +711,7 @@ describe('socket scan create', async () => {
711711
'create',
712712
FLAG_ORG,
713713
'fakeOrg',
714-
'test/fixtures/commands/scan/reach',
714+
'test/fixtures/commands/scan/simple-npm',
715715
FLAG_DRY_RUN,
716716
'--repo',
717717
'xyz',
@@ -736,7 +736,7 @@ describe('socket scan create', async () => {
736736
'create',
737737
FLAG_ORG,
738738
'fakeOrg',
739-
'test/fixtures/commands/scan/reach',
739+
'test/fixtures/commands/scan/simple-npm',
740740
FLAG_DRY_RUN,
741741
'--repo',
742742
'xyz',
@@ -761,7 +761,7 @@ describe('socket scan create', async () => {
761761
'create',
762762
FLAG_ORG,
763763
'fakeOrg',
764-
'test/fixtures/commands/scan/reach',
764+
'test/fixtures/commands/scan/simple-npm',
765765
FLAG_DRY_RUN,
766766
'--repo',
767767
'xyz',
@@ -791,7 +791,7 @@ describe('socket scan create', async () => {
791791
'create',
792792
FLAG_ORG,
793793
'fakeOrg',
794-
'test/fixtures/commands/scan/reach',
794+
'test/fixtures/commands/scan/simple-npm',
795795
FLAG_DRY_RUN,
796796
'--repo',
797797
'xyz',

0 commit comments

Comments
 (0)