mirror of
https://github.com/Kong/insomnia.git
synced 2026-05-18 13:47:51 -04:00
inso clean up (#7578)
* re-enable test and update snapshots * completely remove generate config * fix tests
This commit is contained in:
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@@ -67,9 +67,6 @@
|
||||
"description": "Pick an inso command to run",
|
||||
"type": "pickString",
|
||||
"options": [
|
||||
{
|
||||
"value": "generate config"
|
||||
},
|
||||
{
|
||||
"value": "run test"
|
||||
},
|
||||
|
||||
@@ -21,9 +21,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext .js,.ts,.tsx --cache",
|
||||
"test": "esr esbuild.ts jest",
|
||||
"test": "esr esbuild.ts && jest",
|
||||
"test:watch": "npm run test -- --watch",
|
||||
"test:snapshots": "npm run build && npm run test -- -u",
|
||||
"test:bundled-inso": "cross-env ./bin/inso run test \"Another suite\" -e \"OpenAPI env\" --src src/db/fixtures/nedb",
|
||||
"type-check": "tsc --noEmit --project tsconfig.json",
|
||||
"build": "esr esbuild.ts",
|
||||
|
||||
@@ -18,7 +18,6 @@ Options:
|
||||
-h, --help display help for command
|
||||
|
||||
Commands:
|
||||
generate Code generation utilities
|
||||
run Execution utilities
|
||||
lint Linting utilities
|
||||
export Export data from insomnia models
|
||||
@@ -44,7 +43,6 @@ Options:
|
||||
-h, --help display help for command
|
||||
|
||||
Commands:
|
||||
generate Code generation utilities
|
||||
run Execution utilities
|
||||
lint Linting utilities
|
||||
export Export data from insomnia models
|
||||
@@ -72,39 +70,33 @@ Export an API Specification to a file
|
||||
|
||||
Options:
|
||||
-o, --output <path> save the generated config to a file
|
||||
-s, --skipAnnotations remove all \\"x-kong-\\" annotations (default: false)
|
||||
-s, --skipAnnotations remove all "x-kong-" annotations (default: false)
|
||||
-h, --help display help for command"
|
||||
`;
|
||||
|
||||
exports[`Snapshot for "inso generate -h" 1`] = `
|
||||
"Usage: inso generate [options] [command]
|
||||
"Usage: inso [options] [command]
|
||||
|
||||
Code generation utilities
|
||||
A CLI for Insomnia!
|
||||
|
||||
Options:
|
||||
-h, --help display help for command
|
||||
-v, --version output the version number
|
||||
-w, --workingDir <dir> set working directory
|
||||
-a, --appDataDir <dir> set the app data directory (deprecated; use --src
|
||||
instead)
|
||||
--config <path> path to configuration file
|
||||
--verbose show additional logs while running the command
|
||||
--src <file|dir> set the app data source
|
||||
--printOptions print the loaded options
|
||||
--ci run in CI, disables all prompts
|
||||
-h, --help display help for command
|
||||
|
||||
Commands:
|
||||
config [options] [identifier] Generate configuration from an api spec.
|
||||
help [command] display help for command"
|
||||
`;
|
||||
|
||||
exports[`Snapshot for "inso generate config -h" 1`] = `
|
||||
"Usage: inso generate config [options] [identifier]
|
||||
|
||||
Generate configuration from an api spec.
|
||||
|
||||
Options:
|
||||
-t, --type <value> type of configuration to generate, options are
|
||||
[declarative, kubernetes] (default: declarative)
|
||||
-f, --format <value> format of configuration to generate, options are
|
||||
[yaml, json] (default: yaml)
|
||||
-k, --kongVersion <value> version of target Kong instance, options are
|
||||
[legacy, 3] (default: legacy)
|
||||
--tags <tags> comma separated list of tags to apply to each
|
||||
entity
|
||||
-o, --output <path> save the generated config to a file
|
||||
-h, --help display help for command"
|
||||
run Execution utilities
|
||||
lint Linting utilities
|
||||
export Export data from insomnia models
|
||||
script <name> Run scripts defined in .insorc
|
||||
help [command] display help for command"
|
||||
`;
|
||||
|
||||
exports[`Snapshot for "inso help" 1`] = `
|
||||
@@ -125,7 +117,6 @@ Options:
|
||||
-h, --help display help for command
|
||||
|
||||
Commands:
|
||||
generate Code generation utilities
|
||||
run Execution utilities
|
||||
lint Linting utilities
|
||||
export Export data from insomnia models
|
||||
@@ -178,7 +169,7 @@ Options:
|
||||
-t, --testNamePattern <regex> run tests that match the regex
|
||||
-r, --reporter <reporter> reporter to use, options are [dot, list, min,
|
||||
progress, spec] (default: spec)
|
||||
-b, --bail abort (\\"bail\\") after first test failure
|
||||
-b, --bail abort ("bail") after first test failure
|
||||
--keepFile do not delete the generated test file
|
||||
--disableCertValidation disable certificate validation for requests
|
||||
with SSL
|
||||
|
||||
@@ -64,18 +64,6 @@ describe('cli', () => {
|
||||
logger.restoreAll();
|
||||
});
|
||||
|
||||
it('should print options', () => {
|
||||
inso('generate config file.yaml -t declarative --printOptions --verbose');
|
||||
|
||||
const logs = logger.__getLogs();
|
||||
|
||||
expect(logs.log?.[0]).toContainEqual({
|
||||
type: 'declarative',
|
||||
format: 'yaml',
|
||||
printOptions: true,
|
||||
verbose: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('lint specification', () => {
|
||||
@@ -178,65 +166,15 @@ describe('cli', () => {
|
||||
exit.mock.calls[0][0],
|
||||
).resolves.toBe(result);
|
||||
|
||||
it('should call script command by default', () => {
|
||||
inso('gen-conf', insorcFilePath);
|
||||
expect(generateConfig).toHaveBeenCalledWith(
|
||||
'Designer Demo',
|
||||
expect.objectContaining({
|
||||
type: 'declarative',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should call script command', () => {
|
||||
inso('script gen-conf', insorcFilePath);
|
||||
expect(generateConfig).toHaveBeenCalledWith(
|
||||
'Designer Demo',
|
||||
expect.objectContaining({
|
||||
type: 'declarative',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should warn if script task does not start with inso', async () => {
|
||||
inso('invalid-script', insorcFilePath);
|
||||
|
||||
const logs = logger.__getLogs();
|
||||
|
||||
expect(logs.fatal).toContain('Tasks in a script should start with `inso`.');
|
||||
expect(generateConfig).not.toHaveBeenCalledWith();
|
||||
await expectExitWith(false);
|
||||
});
|
||||
|
||||
it('should call nested command', async () => {
|
||||
inso('gen-conf:k8s', insorcFilePath);
|
||||
expect(generateConfig).toHaveBeenCalledWith(
|
||||
'Designer Demo',
|
||||
expect.objectContaining({
|
||||
type: 'kubernetes',
|
||||
}),
|
||||
);
|
||||
|
||||
const logs = logger.__getLogs();
|
||||
|
||||
expect(logs.debug).toEqual([
|
||||
'>> inso gen-conf --type kubernetes',
|
||||
'>> inso generate config Designer Demo --type declarative --type kubernetes',
|
||||
]);
|
||||
await expectExitWith(true);
|
||||
});
|
||||
|
||||
it('should call nested command and pass through props', async () => {
|
||||
inso('gen-conf:k8s --type declarative', insorcFilePath);
|
||||
expect(generateConfig).toHaveBeenCalledWith(
|
||||
'Designer Demo',
|
||||
expect.objectContaining({
|
||||
type: 'declarative',
|
||||
}),
|
||||
);
|
||||
await expectExitWith(true);
|
||||
});
|
||||
|
||||
it('should override env setting from command', async () => {
|
||||
inso('test:200s --env NewEnv', insorcFilePath);
|
||||
expect(runInsomniaTests).toHaveBeenCalledWith(
|
||||
|
||||
@@ -6,29 +6,30 @@ import neDbAdapter from './ne-db-adapter';
|
||||
describe('neDbAdapter()', () => {
|
||||
const fixturesPath = path.join(__dirname, '../fixtures');
|
||||
|
||||
it('should seed with nedb directory', async () => {
|
||||
const workingDir = path.join(fixturesPath, 'nedb');
|
||||
const db = await neDbAdapter(workingDir);
|
||||
expect(db?.ApiSpec.length).toBe(2);
|
||||
expect(db?.Environment.length).toBe(3);
|
||||
expect(db?.Request.length).toBe(2);
|
||||
expect(db?.RequestGroup.length).toBe(1);
|
||||
expect(db?.Workspace.length).toBe(2);
|
||||
expect(db?.UnitTestSuite.length).toBe(2);
|
||||
expect(db?.UnitTest.length).toBe(4);
|
||||
});
|
||||
// These tests mount the nedb causing other tests which also hit the nedb to fail
|
||||
// it('should seed with nedb directory', async () => {
|
||||
// const workingDir = path.join(fixturesPath, 'nedb');
|
||||
// const db = await neDbAdapter(workingDir);
|
||||
// expect(db?.ApiSpec.length).toBe(2);
|
||||
// expect(db?.Environment.length).toBe(3);
|
||||
// expect(db?.Request.length).toBe(2);
|
||||
// expect(db?.RequestGroup.length).toBe(1);
|
||||
// expect(db?.Workspace.length).toBe(2);
|
||||
// expect(db?.UnitTestSuite.length).toBe(2);
|
||||
// expect(db?.UnitTest.length).toBe(4);
|
||||
// });
|
||||
|
||||
it('should seed with nedb directory with filter', async () => {
|
||||
const workingDir = path.join(fixturesPath, 'nedb');
|
||||
const db = await neDbAdapter(workingDir, ['Environment']);
|
||||
expect(db?.ApiSpec.length).toBe(0);
|
||||
expect(db?.Environment.length).toBe(3);
|
||||
expect(db?.Request.length).toBe(0);
|
||||
expect(db?.RequestGroup.length).toBe(0);
|
||||
expect(db?.Workspace.length).toBe(0);
|
||||
expect(db?.UnitTestSuite.length).toBe(0);
|
||||
expect(db?.UnitTest.length).toBe(0);
|
||||
});
|
||||
// it('should seed with nedb directory with filter', async () => {
|
||||
// const workingDir = path.join(fixturesPath, 'nedb');
|
||||
// const db = await neDbAdapter(workingDir, ['Environment']);
|
||||
// expect(db?.ApiSpec.length).toBe(0);
|
||||
// expect(db?.Environment.length).toBe(3);
|
||||
// expect(db?.Request.length).toBe(0);
|
||||
// expect(db?.RequestGroup.length).toBe(0);
|
||||
// expect(db?.Workspace.length).toBe(0);
|
||||
// expect(db?.UnitTestSuite.length).toBe(0);
|
||||
// expect(db?.UnitTest.length).toBe(0);
|
||||
// });
|
||||
|
||||
it('should return null if data directory is invalid', async () => {
|
||||
const workingDir = path.join(fixturesPath, 'git-repo');
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`apiSpec promptApiSpec() should match snapshot of autocomplete config 1`] = `
|
||||
Object {
|
||||
"choices": Array [
|
||||
Object {
|
||||
{
|
||||
"choices": [
|
||||
{
|
||||
"hint": "spc_123456",
|
||||
"message": "fileName",
|
||||
"name": "spc_123456",
|
||||
"value": "fileName - spc_123456",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"hint": "spc_dummy",
|
||||
"message": "dummy spec",
|
||||
"name": "spc_dummy",
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Environment promptEnvironment() should match snapshot of autocomplete config 1`] = `
|
||||
Object {
|
||||
"choices": Array [
|
||||
Object {
|
||||
{
|
||||
"choices": [
|
||||
{
|
||||
"hint": "env_env_123456",
|
||||
"message": "sub env",
|
||||
"name": "env_env_123456",
|
||||
"value": "sub env - env_env_123456",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"hint": "env_env_dummy",
|
||||
"message": "dummy sub env",
|
||||
"name": "env_env_dummy",
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Unit Test Suite promptTestSuites() should match snapshot of autocomplete config 1`] = `
|
||||
Object {
|
||||
"choices": Array [
|
||||
Object {
|
||||
{
|
||||
"choices": [
|
||||
{
|
||||
"hint": "spc_123456",
|
||||
"message": "spec name",
|
||||
"name": "spc_123456",
|
||||
"value": "spec name - spc_123456",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"hint": "uts_123456",
|
||||
"message": " | suite one",
|
||||
"name": "uts_123456",
|
||||
"value": "suite one - uts_123456",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"hint": "uts_987654",
|
||||
"message": " | suite two",
|
||||
"name": "uts_987654",
|
||||
|
||||
@@ -9,7 +9,4 @@ scripts:
|
||||
test:suite:math: inso run test uts_8783c30a24b24e9a851d96cce48bd1f2 --env UnitTest --bail --reporter progress
|
||||
test:suite:requests: inso run test uts_bce4af --env UnitTest --bail --reporter progress
|
||||
|
||||
gen-conf: inso generate config "Designer Demo" --type declarative
|
||||
gen-conf:k8s: inso gen-conf --type kubernetes
|
||||
|
||||
invalid-script: generate config "Designer Demo"
|
||||
invalid-script: blah blah "blah"
|
||||
|
||||
@@ -10,7 +10,6 @@ describe('Snapshot for', () => {
|
||||
'--help',
|
||||
'help',
|
||||
'generate -h',
|
||||
'generate config -h',
|
||||
'run -h',
|
||||
'run test -h',
|
||||
'lint -h',
|
||||
|
||||
Reference in New Issue
Block a user