Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/commands/analytics/cmd-analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ describe('socket analytics', async () => {
// Lazily access constants.rootBinPath.
const entryPath = path.join(constants.rootBinPath, `${CLI}.js`)

cmdit(['analytics', '--help'], 'should support --help', async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
cmdit(
['analytics', '--help', '--config', '{}'],
'should support --help',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Look up analytics data

Usage
Expand All @@ -38,23 +41,24 @@ describe('socket analytics', async () => {
$ socket analytics --scope=org --time=30
$ socket analytics --scope=repo --repo=test-repo --time=30"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'header should include command (without params)').toContain(
'`socket analytics`'
)
})
expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket analytics`'
)
}
)

cmdit(
['analytics', '--dry-run'],
['analytics', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
30 changes: 17 additions & 13 deletions src/commands/audit-log/cmd-audit-log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ describe('socket audit-log', async () => {
// Lazily access constants.rootBinPath.
const entryPath = path.join(constants.rootBinPath, `${CLI}.js`)

cmdit(['audit-log', '--help'], 'should support --help', async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
cmdit(
['audit-log', '--help', '--config', '{}'],
'should support --help',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Look up the audit log for an organization

Usage
Expand All @@ -35,23 +38,24 @@ describe('socket audit-log', async () => {
Examples
$ socket audit-log FakeOrg"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket audit-log\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'header should include command (without params)').toContain(
'`socket audit-log`'
)
})
expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket audit-log`'
)
}
)

cmdit(
['audit-log', '--dry-run'],
['audit-log', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand All @@ -73,7 +77,7 @@ describe('socket audit-log', async () => {
)

cmdit(
['audit-log', 'fakeorg', '--dry-run'],
['audit-log', 'fakeorg', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
6 changes: 2 additions & 4 deletions src/commands/cdxgen/cmd-cdxgen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@ describe('socket cdxgen', async () => {

// expect(code, 'help should exit with code 2').toBe(2)
expect(code, 'help should exit with code 2').toBe(0) // cdxgen special case
expect(stderr, 'header should include command (without params)').toContain(
'`socket cdxgen`'
)
expect(stderr, 'banner includes base command').toContain('`socket cdxgen`')
})

// cdxgen does not support --dry-run
// cmdit(
// ['cdxgen', '--dry-run'],
// ['cdxgen', '--help', '--config', '{}'],
// 'should require args with just dry-run',
// async cmd => {
// const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
2 changes: 0 additions & 2 deletions src/commands/cdxgen/cmd-cdxgen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// import { meowOrExit } from '../../utils/meow-with-subcommands'
import process from 'node:process'

import yargsParse from 'yargs-parser'

import { logger } from '@socketsecurity/registry/lib/logger'
Expand Down
30 changes: 17 additions & 13 deletions src/commands/config/cmd-config-get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ describe('socket config get', async () => {
// Lazily access constants.rootBinPath.
const entryPath = path.join(constants.rootBinPath, `${CLI}.js`)

cmdit(['config', 'get', '--help'], 'should support --help', async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
cmdit(
['config', 'get', '--help', '--config', '{}'],
'should support --help',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Get the value of a local CLI config item

Usage
Expand All @@ -37,23 +40,24 @@ describe('socket config get', async () => {
Examples
$ socket config get FakeOrg --repoName=test-repo"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket config get\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'header should include command (without params)').toContain(
'`socket config get`'
)
})
expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket config get`'
)
}
)

cmdit(
['config', 'get', '--dry-run'],
['config', 'get', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand All @@ -75,7 +79,7 @@ describe('socket config get', async () => {
)

cmdit(
['config', 'get', 'test', '--dry-run'],
['config', 'get', 'test', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
28 changes: 16 additions & 12 deletions src/commands/config/cmd-config-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ describe('socket config get', async () => {
// Lazily access constants.rootBinPath.
const entryPath = path.join(constants.rootBinPath, `${CLI}.js`)

cmdit(['config', 'list', '--help'], 'should support --help', async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
cmdit(
['config', 'list', '--help', '--config', '{}'],
'should support --help',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Show all local CLI config items and their values

Usage
Expand All @@ -38,23 +41,24 @@ describe('socket config get', async () => {
Examples
$ socket config list FakeOrg --repoName=test-repo"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket config list\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'header should include command (without params)').toContain(
'`socket config list`'
)
})
expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket config list`'
)
}
)

cmdit(
['config', 'list', '--dry-run'],
['config', 'list', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
30 changes: 17 additions & 13 deletions src/commands/config/cmd-config-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ describe('socket config get', async () => {
// Lazily access constants.rootBinPath.
const entryPath = path.join(constants.rootBinPath, `${CLI}.js`)

cmdit(['config', 'set', '--help'], 'should support --help', async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
cmdit(
['config', 'set', '--help', '--config', '{}'],
'should support --help',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Update the value of a local CLI config item

Usage
Expand Down Expand Up @@ -42,23 +45,24 @@ describe('socket config get', async () => {
Examples
$ socket config set apiProxy https://example.com"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket config set\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'header should include command (without params)').toContain(
'`socket config set`'
)
})
expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket config set`'
)
}
)

cmdit(
['config', 'set', '--dry-run'],
['config', 'set', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand All @@ -82,7 +86,7 @@ describe('socket config get', async () => {
)

cmdit(
['config', 'set', 'test', 'xyz', '--dry-run'],
['config', 'set', 'test', 'xyz', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
30 changes: 17 additions & 13 deletions src/commands/config/cmd-config-unset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ describe('socket config unset', async () => {
// Lazily access constants.rootBinPath.
const entryPath = path.join(constants.rootBinPath, `${CLI}.js`)

cmdit(['config', 'unset', '--help'], 'should support --help', async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
cmdit(
['config', 'unset', '--help', '--config', '{}'],
'should support --help',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Clear the value of a local CLI config item

Usage
Expand All @@ -37,23 +40,24 @@ describe('socket config unset', async () => {
Examples
$ socket config unset FakeOrg --repoName=test-repo"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
|__ | . | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket config unset\`, cwd: <redacted>"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'header should include command (without params)').toContain(
'`socket config unset`'
)
})
expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket config unset`'
)
}
)

cmdit(
['config', 'unset', '--dry-run'],
['config', 'unset', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand All @@ -75,7 +79,7 @@ describe('socket config unset', async () => {
)

cmdit(
['config', 'unset', 'test', '--dry-run'],
['config', 'unset', 'test', '--dry-run', '--config', '{}'],
'should require args with just dry-run',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
Expand Down
Loading
Loading