-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): Introduce config environment command
- Loading branch information
1 parent
4c0f6e0
commit 0d8dd2b
Showing
3 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
test/jest/acceptance/snyk-config/snyk-config-environment.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { runSnykCLI } from '../../util/runSnykCLI'; | ||
import { | ||
getCliConfig, | ||
restoreCliConfig, | ||
} from '../../../acceptance/config-helper'; | ||
|
||
jest.setTimeout(1000 * 30); | ||
|
||
describe('snyk config environment', () => { | ||
let initialConfig: Record<string, string> = {}; | ||
|
||
beforeEach(async () => { | ||
initialConfig = await getCliConfig(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await restoreCliConfig(initialConfig); | ||
}); | ||
|
||
it('successfully configure with a partial DNS name', async () => { | ||
const { code, stderr } = await runSnykCLI(`config environment dev`); | ||
expect(stderr).toEqual(''); | ||
expect(code).toEqual(0); | ||
|
||
const { stdout } = await runSnykCLI(`config get endpoint`); | ||
expect(stdout.trim()).toEqual('https://api.dev.snyk.io'); | ||
}); | ||
|
||
it('successfully configure with a URL', async () => { | ||
const { code, stderr } = await runSnykCLI( | ||
`config environment https://api.dev.snyk.io`, | ||
); | ||
expect(stderr).toEqual(''); | ||
expect(code).toEqual(0); | ||
|
||
const { stdout } = await runSnykCLI(`config get endpoint`); | ||
expect(stdout.trim()).toEqual('https://api.dev.snyk.io'); | ||
}); | ||
|
||
it('fail with an invalid env alias', async () => { | ||
const { code, stderr } = await runSnykCLI( | ||
`config environment randomEnvName`, | ||
); | ||
expect(stderr).toEqual(''); | ||
expect(code).toEqual(2); | ||
}); | ||
}); |