Skip to content

Commit 6a7e814

Browse files
committed
Update test utils
1 parent 43d7798 commit 6a7e814

File tree

65 files changed

+436
-441
lines changed

Some content is hidden

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

65 files changed

+436
-441
lines changed

src/commands/analytics/cmd-analytics.test.mts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import semver from 'semver'
22
import { describe, expect } from 'vitest'
33

44
import constants from '../../../src/constants.mts'
5-
import { cmdit, spawnPnpm } from '../../../test/utils.mts'
5+
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
66

77
describe('socket analytics', async () => {
88
const { binCliPath } = constants
@@ -11,7 +11,7 @@ describe('socket analytics', async () => {
1111
['analytics', '--help', '--config', '{}'],
1212
'should support --help',
1313
async cmd => {
14-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
14+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1515
expect(stdout).toMatchInlineSnapshot(
1616
`
1717
"Look up analytics data
@@ -65,7 +65,7 @@ describe('socket analytics', async () => {
6565
['analytics', '--dry-run', '--config', '{}'],
6666
'should report missing token with just dry-run',
6767
async cmd => {
68-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
68+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
6969
expect(stdout).toMatchInlineSnapshot(`""`)
7070
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
7171
"
@@ -97,7 +97,7 @@ describe('socket analytics', async () => {
9797
],
9898
'should reject legacy flags',
9999
async cmd => {
100-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
100+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
101101
expect(stdout).toMatchInlineSnapshot(`""`)
102102
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
103103
"
@@ -120,7 +120,7 @@ describe('socket analytics', async () => {
120120
['analytics', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
121121
'should run to dryrun without args',
122122
async cmd => {
123-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
123+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
124124
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
125125
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
126126
"
@@ -138,7 +138,7 @@ describe('socket analytics', async () => {
138138
['analytics', 'org', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
139139
'should accept org arg',
140140
async cmd => {
141-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
141+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
142142
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
143143
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
144144
"
@@ -156,7 +156,7 @@ describe('socket analytics', async () => {
156156
['analytics', 'repo', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
157157
'should ask for repo name with repo arg',
158158
async cmd => {
159-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
159+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
160160
expect(stdout).toMatchInlineSnapshot(`""`)
161161
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
162162
"
@@ -186,7 +186,7 @@ describe('socket analytics', async () => {
186186
],
187187
'should accept repo with arg',
188188
async cmd => {
189-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
189+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
190190
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
191191
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
192192
"
@@ -204,7 +204,7 @@ describe('socket analytics', async () => {
204204
['analytics', '7', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
205205
'should accept time 7 arg',
206206
async cmd => {
207-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
207+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
208208
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
209209
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
210210
"
@@ -222,7 +222,7 @@ describe('socket analytics', async () => {
222222
['analytics', '30', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
223223
'should accept time 30 arg',
224224
async cmd => {
225-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
225+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
226226
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
227227
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
228228
"
@@ -240,7 +240,7 @@ describe('socket analytics', async () => {
240240
['analytics', '90', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
241241
'should accept time 90 arg',
242242
async cmd => {
243-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
243+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
244244
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
245245
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
246246
"
@@ -266,7 +266,7 @@ describe('socket analytics', async () => {
266266
],
267267
'should report legacy flag',
268268
async cmd => {
269-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
269+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
270270
expect(stdout).toMatchInlineSnapshot(`""`)
271271
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
272272
"
@@ -296,7 +296,7 @@ describe('socket analytics', async () => {
296296
],
297297
'should accept org and time arg',
298298
async cmd => {
299-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
299+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
300300
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
301301
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
302302
"
@@ -322,7 +322,7 @@ describe('socket analytics', async () => {
322322
],
323323
'should accept repo and time arg',
324324
async cmd => {
325-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
325+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
326326
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
327327
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
328328
"

src/commands/audit-log/cmd-audit-log.test.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect } from 'vitest'
22

33
import constants from '../../../src/constants.mts'
4-
import { cmdit, spawnPnpm } from '../../../test/utils.mts'
4+
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
55

66
describe('socket audit-log', async () => {
77
const { binCliPath } = constants
@@ -10,7 +10,7 @@ describe('socket audit-log', async () => {
1010
['audit-log', '--help', '--config', '{}'],
1111
'should support --help',
1212
async cmd => {
13-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
13+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1414
expect(stdout).toMatchInlineSnapshot(
1515
`
1616
"Look up the audit log for an organization
@@ -70,7 +70,7 @@ describe('socket audit-log', async () => {
7070
['audit-log', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
7171
'should report missing org name',
7272
async cmd => {
73-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
73+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
7474
expect(stdout).toMatchInlineSnapshot(`""`)
7575
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
7676
"
@@ -104,7 +104,7 @@ describe('socket audit-log', async () => {
104104
],
105105
'should report legacy flag',
106106
async cmd => {
107-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
107+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
108108
expect(stdout).toMatchInlineSnapshot(`""`)
109109
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
110110
"
@@ -131,7 +131,7 @@ describe('socket audit-log', async () => {
131131
],
132132
'should accept default org',
133133
async cmd => {
134-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
134+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
135135
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
136136
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
137137
"
@@ -156,7 +156,7 @@ describe('socket audit-log', async () => {
156156
],
157157
'should accept --org flag in v1',
158158
async cmd => {
159-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
159+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
160160
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
161161
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
162162
"

src/commands/ci/cmd-ci.test.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect } from 'vitest'
22

33
import constants from '../../../src/constants.mts'
4-
import { cmdit, spawnPnpm } from '../../../test/utils.mts'
4+
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
55

66
describe('socket ci', async () => {
77
const { binCliPath } = constants
@@ -10,7 +10,7 @@ describe('socket ci', async () => {
1010
['ci', '--help', '--config', '{}'],
1111
'should support --help',
1212
async cmd => {
13-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
13+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1414
expect(stdout).toMatchInlineSnapshot(
1515
`
1616
"Shorthand for \`socket scan create --report --no-interactive\`
@@ -53,7 +53,7 @@ describe('socket ci', async () => {
5353
['ci', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
5454
'should require args with just dry-run',
5555
async cmd => {
56-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
56+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
5757
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
5858
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
5959
"

src/commands/cli.test.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { describe, expect } from 'vitest'
22

3-
import { cmdit, spawnPnpm } from '../../test/utils.mts'
3+
import { cmdit, spawnSocketCli } from '../../test/utils.mts'
44
import constants, { API_V0_URL } from '../constants.mts'
55

66
describe('socket root command', async () => {
77
const { binCliPath } = constants
88

99
cmdit(['--help', '--config', '{}'], 'should support --help', async cmd => {
10-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
10+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1111
expect(stdout).toMatchInlineSnapshot(`
1212
"CLI for Socket.dev
1313
@@ -106,7 +106,7 @@ describe('socket root command', async () => {
106106
['mootools', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
107107
'should require args with just dry-run',
108108
async cmd => {
109-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
109+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
110110
expect(stdout).toMatchInlineSnapshot(
111111
`"[DryRun]: No-op, call a sub-command; ok"`,
112112
)

src/commands/config/cmd-config-auto.test.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect } from 'vitest'
22

33
import constants from '../../../src/constants.mts'
4-
import { cmdit, spawnPnpm } from '../../../test/utils.mts'
4+
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
55

66
describe('socket config auto', async () => {
77
const { binCliPath } = constants
@@ -10,7 +10,7 @@ describe('socket config auto', async () => {
1010
['config', 'auto', '--help', '--config', '{}'],
1111
'should support --help',
1212
async cmd => {
13-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
13+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1414
expect(stdout).toMatchInlineSnapshot(
1515
`
1616
"Automatically discover and set the correct value config item
@@ -63,7 +63,7 @@ describe('socket config auto', async () => {
6363
],
6464
'should require args with just dry-run',
6565
async cmd => {
66-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
66+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
6767
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
6868
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
6969
"

src/commands/config/cmd-config-get.test.mts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import semver from 'semver'
22
import { describe, expect } from 'vitest'
33

44
import constants from '../../../src/constants.mts'
5-
import { cmdit, spawnPnpm } from '../../../test/utils.mts'
5+
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
66

77
describe('socket config get', async () => {
88
const { binCliPath } = constants
@@ -11,7 +11,7 @@ describe('socket config get', async () => {
1111
['config', 'get', '--help', '--config', '{}'],
1212
'should support --help',
1313
async cmd => {
14-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
14+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1515
expect(stdout).toMatchInlineSnapshot(
1616
`
1717
"Get the value of a local CLI config item
@@ -65,7 +65,7 @@ describe('socket config get', async () => {
6565
['config', 'get', '--dry-run', '--config', '{}'],
6666
'should require args with just dry-run',
6767
async cmd => {
68-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
68+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
6969
expect(stdout).toMatchInlineSnapshot(`""`)
7070
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
7171
"
@@ -94,7 +94,7 @@ describe('socket config get', async () => {
9494
],
9595
'should require args with just dry-run',
9696
async cmd => {
97-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
97+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
9898
expect(stdout).toMatchInlineSnapshot(
9999
`"[DryRun]: No-op, call a sub-command; ok"`,
100100
)
@@ -116,7 +116,7 @@ describe('socket config get', async () => {
116116
['config', 'get', 'apiToken', '--config', '{"apiToken":null}'],
117117
'should return undefined when token not set in config',
118118
async cmd => {
119-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd)
119+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
120120
expect(stdout).toMatchInlineSnapshot(
121121
`
122122
"apiToken: null
@@ -140,7 +140,7 @@ describe('socket config get', async () => {
140140
['config', 'get', 'apiToken', '--config', '{"apiToken":null}'],
141141
'should return the env var token when set',
142142
async cmd => {
143-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd, {
143+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
144144
env: { SOCKET_CLI_API_TOKEN: 'abc' },
145145
})
146146
expect(stdout).toMatchInlineSnapshot(
@@ -167,7 +167,7 @@ describe('socket config get', async () => {
167167
['config', 'get', 'apiToken', '--config', '{"apiToken":null}'],
168168
'should back compat support for API token as well env var',
169169
async cmd => {
170-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd, {
170+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
171171
env: { SOCKET_SECURITY_API_KEY: 'abc' },
172172
})
173173
expect(stdout).toMatchInlineSnapshot(
@@ -193,7 +193,7 @@ describe('socket config get', async () => {
193193
['config', 'get', 'apiToken', '--config', '{"apiToken":null}'],
194194
'should be nice and support cli prefixed env var for token as well',
195195
async cmd => {
196-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd, {
196+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
197197
env: { SOCKET_CLI_API_TOKEN: 'abc' },
198198
})
199199
expect(stdout).toMatchInlineSnapshot(
@@ -220,7 +220,7 @@ describe('socket config get', async () => {
220220
['config', 'get', 'apiToken', '--config', '{"apiToken":null}'],
221221
'should be very nice and support cli prefixed env var for key as well since it is an easy mistake to make',
222222
async cmd => {
223-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd, {
223+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
224224
env: { SOCKET_CLI_API_KEY: 'abc' },
225225
})
226226
expect(stdout).toMatchInlineSnapshot(
@@ -252,7 +252,7 @@ describe('socket config get', async () => {
252252
],
253253
'should use the env var token when the config override also has a token set',
254254
async cmd => {
255-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd, {
255+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd, {
256256
env: { SOCKET_CLI_API_KEY: 'abc' },
257257
})
258258
expect(stdout).toMatchInlineSnapshot(
@@ -284,7 +284,7 @@ describe('socket config get', async () => {
284284
],
285285
'should use the config override when there is no env var',
286286
async cmd => {
287-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd)
287+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
288288
expect(stdout).toMatchInlineSnapshot(
289289
`
290290
"apiToken: pickmepickme
@@ -308,7 +308,7 @@ describe('socket config get', async () => {
308308
['config', 'get', 'apiToken', '--config', '{}'],
309309
'should yield no token when override has none',
310310
async cmd => {
311-
const { stderr, stdout } = await spawnPnpm(binCliPath, cmd)
311+
const { stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
312312
expect(stdout).toMatchInlineSnapshot(
313313
`
314314
"apiToken: undefined

src/commands/config/cmd-config-list.test.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path'
33
import { describe, expect } from 'vitest'
44

55
import constants from '../../../src/constants.mts'
6-
import { cmdit, spawnPnpm } from '../../../test/utils.mts'
6+
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
77

88
describe('socket config get', async () => {
99
const { binCliPath } = constants
@@ -12,7 +12,7 @@ describe('socket config get', async () => {
1212
['config', 'list', '--help', '--config', '{}'],
1313
'should support --help',
1414
async cmd => {
15-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
15+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1616
expect(stdout).toMatchInlineSnapshot(
1717
`
1818
"Show all local CLI config items and their values
@@ -48,7 +48,7 @@ describe('socket config get', async () => {
4848
['config', 'list', '--dry-run', '--config', '{"apiToken":"fakeToken"}'],
4949
'should require args with just dry-run',
5050
async cmd => {
51-
const { code, stderr, stdout } = await spawnPnpm(binCliPath, cmd)
51+
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
5252
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
5353
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
5454
"

0 commit comments

Comments
 (0)