Skip to content

Commit 702e5f8

Browse files
committed
fix(test): fix scan create tests to use valid directory targets
Changed 'target' (which doesn't exist) to '.' (current directory) in scan create tests with --reach flag. The --reach flag requires an existing directory path as the target. All 25 scan create tests now pass.
1 parent 8896e22 commit 702e5f8

File tree

1 file changed

+32
-38
lines changed

1 file changed

+32
-38
lines changed

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

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('socket scan create', async () => {
117117
'create',
118118
FLAG_ORG,
119119
'fakeOrg',
120-
'target',
120+
'.',
121121
FLAG_DRY_RUN,
122122
'--repo',
123123
'xyz',
@@ -148,7 +148,7 @@ describe('socket scan create', async () => {
148148
'create',
149149
FLAG_ORG,
150150
'fakeOrg',
151-
'target',
151+
'.',
152152
FLAG_DRY_RUN,
153153
'--repo',
154154
'xyz',
@@ -179,7 +179,7 @@ describe('socket scan create', async () => {
179179
'create',
180180
FLAG_ORG,
181181
'fakeOrg',
182-
'target',
182+
'.',
183183
FLAG_DRY_RUN,
184184
'--repo',
185185
'xyz',
@@ -204,7 +204,7 @@ describe('socket scan create', async () => {
204204
'create',
205205
FLAG_ORG,
206206
'fakeOrg',
207-
'target',
207+
'.',
208208
FLAG_DRY_RUN,
209209
'--repo',
210210
'xyz',
@@ -236,7 +236,7 @@ describe('socket scan create', async () => {
236236
'create',
237237
FLAG_ORG,
238238
'fakeOrg',
239-
'target',
239+
'.',
240240
FLAG_DRY_RUN,
241241
'--repo',
242242
'xyz',
@@ -268,7 +268,7 @@ describe('socket scan create', async () => {
268268
'create',
269269
FLAG_ORG,
270270
'fakeOrg',
271-
'target',
271+
'.',
272272
FLAG_DRY_RUN,
273273
'--repo',
274274
'xyz',
@@ -302,7 +302,7 @@ describe('socket scan create', async () => {
302302
'create',
303303
FLAG_ORG,
304304
'fakeOrg',
305-
'target',
305+
'.',
306306
FLAG_DRY_RUN,
307307
'--repo',
308308
'xyz',
@@ -322,7 +322,7 @@ describe('socket scan create', async () => {
322322
'should succeed when reachability options are used with --reach',
323323
async cmd => {
324324
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
325-
expect(stdout).toMatchInlineSnapshot(`""`)
325+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
326326
expect(code, 'should exit with code 0 when all flags are valid').toBe(0)
327327
},
328328
)
@@ -333,7 +333,7 @@ describe('socket scan create', async () => {
333333
'create',
334334
FLAG_ORG,
335335
'fakeOrg',
336-
'target',
336+
'.',
337337
FLAG_DRY_RUN,
338338
'--repo',
339339
'xyz',
@@ -367,7 +367,7 @@ describe('socket scan create', async () => {
367367
'create',
368368
FLAG_ORG,
369369
'fakeOrg',
370-
'target',
370+
'.',
371371
FLAG_DRY_RUN,
372372
'--repo',
373373
'xyz',
@@ -391,7 +391,7 @@ describe('socket scan create', async () => {
391391
'should succeed when all reachability options including reachExcludePaths are used with --reach',
392392
async cmd => {
393393
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
394-
expect(stdout).toMatchInlineSnapshot(`""`)
394+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
395395
expect(code, 'should exit with code 0 when all flags are valid').toBe(0)
396396
},
397397
)
@@ -402,7 +402,7 @@ describe('socket scan create', async () => {
402402
'create',
403403
FLAG_ORG,
404404
'fakeOrg',
405-
'target',
405+
'.',
406406
FLAG_DRY_RUN,
407407
'--repo',
408408
'xyz',
@@ -417,7 +417,7 @@ describe('socket scan create', async () => {
417417
'should succeed when --reach-ecosystems is used with comma-separated values',
418418
async cmd => {
419419
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
420-
expect(stdout).toMatchInlineSnapshot(`""`)
420+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
421421
expect(
422422
code,
423423
'should exit with code 0 when comma-separated values are used',
@@ -431,7 +431,7 @@ describe('socket scan create', async () => {
431431
'create',
432432
FLAG_ORG,
433433
'fakeOrg',
434-
'target',
434+
'.',
435435
FLAG_DRY_RUN,
436436
'--repo',
437437
'xyz',
@@ -446,7 +446,7 @@ describe('socket scan create', async () => {
446446
'should succeed when --reach-exclude-paths is used with comma-separated values',
447447
async cmd => {
448448
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
449-
expect(stdout).toMatchInlineSnapshot(`""`)
449+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
450450
expect(
451451
code,
452452
'should exit with code 0 when comma-separated values are used',
@@ -460,7 +460,7 @@ describe('socket scan create', async () => {
460460
'create',
461461
FLAG_ORG,
462462
'fakeOrg',
463-
'target',
463+
'.',
464464
FLAG_DRY_RUN,
465465
'--repo',
466466
'xyz',
@@ -492,7 +492,7 @@ describe('socket scan create', async () => {
492492
'create',
493493
FLAG_ORG,
494494
'fakeOrg',
495-
'target',
495+
'.',
496496
FLAG_DRY_RUN,
497497
'--repo',
498498
'xyz',
@@ -524,7 +524,7 @@ describe('socket scan create', async () => {
524524
'create',
525525
FLAG_ORG,
526526
'fakeOrg',
527-
'target',
527+
'.',
528528
FLAG_DRY_RUN,
529529
'--repo',
530530
'xyz',
@@ -592,7 +592,7 @@ describe('socket scan create', async () => {
592592
'create',
593593
FLAG_ORG,
594594
'fakeOrg',
595-
'target',
595+
'.',
596596
FLAG_DRY_RUN,
597597
'--repo',
598598
'xyz',
@@ -607,7 +607,7 @@ describe('socket scan create', async () => {
607607
'should succeed with minimal positive reachability memory limit',
608608
async cmd => {
609609
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
610-
expect(stdout).toMatchInlineSnapshot(`""`)
610+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
611611
expect(code, 'should exit with code 0').toBe(0)
612612
},
613613
)
@@ -618,7 +618,7 @@ describe('socket scan create', async () => {
618618
'create',
619619
FLAG_ORG,
620620
'fakeOrg',
621-
'target',
621+
'.',
622622
FLAG_DRY_RUN,
623623
'--repo',
624624
'xyz',
@@ -633,7 +633,7 @@ describe('socket scan create', async () => {
633633
'should succeed with zero timeout (unlimited)',
634634
async cmd => {
635635
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
636-
expect(stdout).toMatchInlineSnapshot(`""`)
636+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
637637
expect(code, 'should exit with code 0').toBe(0)
638638
},
639639
)
@@ -644,7 +644,7 @@ describe('socket scan create', async () => {
644644
'create',
645645
FLAG_ORG,
646646
'fakeOrg',
647-
'target',
647+
'.',
648648
FLAG_DRY_RUN,
649649
'--repo',
650650
'xyz',
@@ -674,7 +674,7 @@ describe('socket scan create', async () => {
674674
'create',
675675
FLAG_ORG,
676676
'fakeOrg',
677-
'target',
677+
'.',
678678
FLAG_DRY_RUN,
679679
'--repo',
680680
'xyz',
@@ -696,7 +696,7 @@ describe('socket scan create', async () => {
696696
'should succeed with comprehensive reachability configuration',
697697
async cmd => {
698698
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
699-
expect(stdout).toMatchInlineSnapshot(`""`)
699+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
700700
expect(code, 'should exit with code 0 when all flags are valid').toBe(0)
701701
},
702702
)
@@ -707,7 +707,7 @@ describe('socket scan create', async () => {
707707
'create',
708708
FLAG_ORG,
709709
'fakeOrg',
710-
'target',
710+
'.',
711711
FLAG_DRY_RUN,
712712
'--repo',
713713
'xyz',
@@ -721,13 +721,7 @@ describe('socket scan create', async () => {
721721
'should succeed with --reach and --json output format',
722722
async cmd => {
723723
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
724-
expect(stdout).toMatchInlineSnapshot(`
725-
"{
726-
"ok": false,
727-
"message": "Input error",
728-
"data": "Please review the input requirements and try again\\n\\n \\u221a At least one TARGET (e.g. \`.\` or \`./package.json\`)\\n \\xd7 Reachability analysis target must be a directory when --reach is enabled (provide a directory path, not a file)\\n \\xd7 Target directory must exist when --reach is enabled (provide an existing directory path)"
729-
}"
730-
`)
724+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
731725
expect(code, 'should exit with code 0').toBe(0)
732726
},
733727
)
@@ -738,7 +732,7 @@ describe('socket scan create', async () => {
738732
'create',
739733
FLAG_ORG,
740734
'fakeOrg',
741-
'target',
735+
'.',
742736
FLAG_DRY_RUN,
743737
'--repo',
744738
'xyz',
@@ -752,7 +746,7 @@ describe('socket scan create', async () => {
752746
'should succeed with --reach and --markdown output format',
753747
async cmd => {
754748
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
755-
expect(stdout).toMatchInlineSnapshot(`""`)
749+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
756750
expect(code, 'should exit with code 0').toBe(0)
757751
},
758752
)
@@ -763,7 +757,7 @@ describe('socket scan create', async () => {
763757
'create',
764758
FLAG_ORG,
765759
'fakeOrg',
766-
'target',
760+
'.',
767761
FLAG_DRY_RUN,
768762
'--repo',
769763
'xyz',
@@ -793,7 +787,7 @@ describe('socket scan create', async () => {
793787
'create',
794788
FLAG_ORG,
795789
'fakeOrg',
796-
'target',
790+
'.',
797791
FLAG_DRY_RUN,
798792
'--repo',
799793
'xyz',
@@ -807,7 +801,7 @@ describe('socket scan create', async () => {
807801
'should succeed when combining --reach with --read-only',
808802
async cmd => {
809803
const { code, stdout } = await spawnSocketCli(binCliPath, cmd)
810-
expect(stdout).toMatchInlineSnapshot(`""`)
804+
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
811805
expect(code, 'should exit with code 0').toBe(0)
812806
},
813807
)

0 commit comments

Comments
 (0)