From cea5950eb770e6a3e29dfb1537d259260b268be3 Mon Sep 17 00:00:00 2001 From: Fei Chen Date: Thu, 15 Oct 2020 14:37:34 +0800 Subject: [PATCH 1/6] add exit code for command when running into exception --- packages/command/src/command.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/command/src/command.ts b/packages/command/src/command.ts index daaa95414..d8ee1aaed 100644 --- a/packages/command/src/command.ts +++ b/packages/command/src/command.ts @@ -50,6 +50,9 @@ export abstract class Command extends Base { this.error(err.message) } catch (e) {} } + + // return exit code + this.exit(1) } // Flush telemetry to avoid performance issues From e7ba7294fbbb93e76d63e5ce1d802c2626647ac8 Mon Sep 17 00:00:00 2001 From: Fei Chen Date: Thu, 15 Oct 2020 21:43:44 +0800 Subject: [PATCH 2/6] fix test --- packages/command/test/command.test.ts | 16 +++++++++++++--- packages/luis/test/commands/luis/build.test.ts | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/command/test/command.test.ts b/packages/command/test/command.test.ts index b78d259d1..c7d389a78 100644 --- a/packages/command/test/command.test.ts +++ b/packages/command/test/command.test.ts @@ -19,8 +19,12 @@ describe('command', () => { return Test.run([]) }) - .do(output => expect(output.stderr).to.include('Unknown error during execution. Please file an issue on https://github.com/microsoft/botframework-cli/issues')) + .catch(err => { + expect(err.message).to.include('EEXIT: 1') + }) + .finally(output => expect(output.stderr).to.equal('Unknown error during execution. Please file an issue on https://github.com/microsoft/botframework-cli/issues\nfailure\n')) .it('Errors out') + fancy .stderr() @@ -34,7 +38,10 @@ describe('command', () => { return Test.run([]) }) - .do(output => expect(output.stderr).to.equal('failure\n')) + .catch(err => { + expect(err.message).to.include('EEXIT: 1') + }) + .finally(output => expect(output.stderr).to.equal('failure\n')) .it('Exits with error') fancy @@ -48,7 +55,10 @@ describe('command', () => { return Test.run([]) }) - .do(output => expect(output.stderr).to.equal('failure\n')) + .catch(err => { + expect(err.message).to.include('EEXIT: 1') + }) + .finally(output => expect(output.stderr).to.equal('failure\n')) .it('Handles OCLIF Errors') fancy diff --git a/packages/luis/test/commands/luis/build.test.ts b/packages/luis/test/commands/luis/build.test.ts index 3527938cd..1965eb858 100644 --- a/packages/luis/test/commands/luis/build.test.ts +++ b/packages/luis/test/commands/luis/build.test.ts @@ -20,6 +20,7 @@ describe('luis:build cli parameters test', () => { test .stdout() .command(['luis:build', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Build lu files to train and publish luis applications') }) @@ -28,6 +29,7 @@ describe('luis:build cli parameters test', () => { .stdout() .stderr() .command(['luis:build', '--in', `${path.join(__dirname, './../../fixtures/testcases/lubuild')}`, '--botName', 'Contoso']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing LUIS authoring key. Please pass authoring key with --authoringKey flag') }) @@ -36,6 +38,7 @@ describe('luis:build cli parameters test', () => { .stdout() .stderr() .command(['luis:build', '--authoringKey', uuidv1(), '--botName', 'Contoso']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing input. Please use stdin or pass a file or folder location with --in flag') }) @@ -44,6 +47,7 @@ describe('luis:build cli parameters test', () => { .stdout() .stderr() .command(['luis:build', '--authoringKey', uuidv1(), '--in', `${path.join(__dirname, './../../fixtures/testcases/lubuild')}`]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing bot name. Please pass bot name with --botName flag') }) @@ -52,6 +56,7 @@ describe('luis:build cli parameters test', () => { .stdout() .stderr() .command(['luis:build', '--authoringKey', uuidv1(), '--in', `${path.join(__dirname, './../../fixtures/testcases/lubuild/file-name-duplicated')}`, '--botName', 'Contoso']) + .exit(1) .it('displays an error if files with same name and locale are found', ctx => { expect(ctx.stderr).to.contain('Files with same name and locale are found') }) @@ -60,6 +65,7 @@ describe('luis:build cli parameters test', () => { .stdout() .stderr() .command(['luis:build', '--authoringKey', uuidv1(), '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid_import_file.lu')}`, '--botName', 'Contoso']) + .exit(1) .it('displays an error if error occurs in parsing lu content', ctx => { expect(ctx.stderr).to.contain('Invalid LU file') expect(ctx.stderr).to.contain('bad3.lu') @@ -70,6 +76,7 @@ describe('luis:build cli parameters test', () => { .stdout() .stderr() .command(['luis:build', '--authoringKey', uuidv1(), '--in', `${path.join(__dirname, './../../fixtures/testcases/lubuild')}`, '--botName', 'Contoso', '--dialog', 'cross-train']) + .exit(1) .it('displays an error if option specified by --dialog is not right', ctx => { expect(ctx.stderr).to.contain('Recognizer type specified by --dialog is not right. Please specify [multiLanguage|crosstrained]') }) From 110564265caaadcf6e7ec5194b4b3d5bd54e54fb Mon Sep 17 00:00:00 2001 From: Fei Chen Date: Fri, 16 Oct 2020 15:12:40 +0800 Subject: [PATCH 3/6] adjust test --- packages/chatdown/test/commands/chatdown.test.ts | 1 + .../chatdown/test/commands/chatdown/convert.test.ts | 3 +++ .../config/test/commands/config/set/luis.test.ts | 1 + .../test/commands/config/set/qnamaker.test.ts | 1 + .../test/commands/config/set/telemetry.test.ts | 2 ++ .../test/commands/luis/application/create.test.ts | 4 ++++ .../test/commands/luis/application/delete.test.ts | 4 ++++ .../test/commands/luis/application/import.test.ts | 5 +++++ .../test/commands/luis/application/list.test.ts | 3 +++ .../test/commands/luis/application/publish.test.ts | 3 +++ .../test/commands/luis/application/query.test.ts | 4 ++++ .../test/commands/luis/application/rename.test.ts | 4 ++++ .../test/commands/luis/application/show.test.ts | 2 ++ packages/luis/test/commands/luis/convert.test.ts | 13 +++++++++++++ packages/luis/test/commands/luis/crossTrain.test.ts | 2 ++ .../luis/test/commands/luis/endpoints/list.test.ts | 3 +++ .../luis/test/commands/luis/generate/cs.test.ts | 1 + .../luis/test/commands/luis/generate/ts.test.ts | 1 + packages/luis/test/commands/luis/index.test.ts | 1 + packages/luis/test/commands/luis/test.test.ts | 1 + packages/luis/test/commands/luis/train/run.test.ts | 1 + packages/luis/test/commands/luis/train/show.test.ts | 2 ++ .../luis/test/commands/luis/version/clone.test.ts | 3 +++ .../luis/test/commands/luis/version/delete.test.ts | 4 ++++ .../luis/test/commands/luis/version/export.test.ts | 4 ++++ .../luis/test/commands/luis/version/import.test.ts | 6 ++++++ .../luis/test/commands/luis/version/list.test.ts | 3 +++ .../luis/test/commands/luis/version/rename.test.ts | 4 ++++ .../plugins/test/commands/plugins/index.test.ts | 1 + .../plugins/test/commands/plugins/install.test.ts | 1 + packages/plugins/test/commands/plugins/list.test.ts | 1 + .../plugins/test/commands/plugins/uninstall.test.ts | 1 + .../commands/qnamaker/alterations/replace.test.ts | 1 + .../qnamaker/test/commands/qnamaker/build.test.ts | 5 +++++ .../qnamaker/test/commands/qnamaker/convert.test.ts | 4 ++++ .../test/commands/qnamaker/crossTrain.test.ts | 2 ++ .../test/commands/qnamaker/kb/create.test.ts | 1 + .../qnamaker/test/commands/qnamaker/kb/list.test.ts | 1 + .../test/commands/qnamaker/kb/replace.test.ts | 1 + .../test/commands/qnamaker/kb/update.test.ts | 1 + .../qnamaker/test/commands/qnamaker/train.test.ts | 1 + 41 files changed, 107 insertions(+) diff --git a/packages/chatdown/test/commands/chatdown.test.ts b/packages/chatdown/test/commands/chatdown.test.ts index 0b4c959bc..f23497444 100644 --- a/packages/chatdown/test/commands/chatdown.test.ts +++ b/packages/chatdown/test/commands/chatdown.test.ts @@ -5,6 +5,7 @@ describe('chatdown', () => { test .stdout() .command(['chatdown', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Converts chat dialog files in .') }) diff --git a/packages/chatdown/test/commands/chatdown/convert.test.ts b/packages/chatdown/test/commands/chatdown/convert.test.ts index 761ce9791..697cdf6be 100644 --- a/packages/chatdown/test/commands/chatdown/convert.test.ts +++ b/packages/chatdown/test/commands/chatdown/convert.test.ts @@ -3,6 +3,7 @@ import assert from 'assert'; import fs from 'fs-extra'; import rimraf from 'rimraf'; import {expect, test} from '@oclif/test' +import { exit } from 'process'; const pkg = require('../../../package.json'); @@ -21,6 +22,7 @@ describe('chatdown:convert', function() { test .stdout() .command(['chatdown:convert', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', (ctx: any) => { expect(ctx.stdout).to.contain('Converts chat dialog files in .') }) @@ -28,6 +30,7 @@ describe('chatdown:convert', function() { test .stdout() .command(['chatdown']) + .exit(1) .it('should print the help contents when no input is passed', (ctx: any) => { expect(ctx.stdout).to.contain('Converts chat dialog files in .') }) diff --git a/packages/config/test/commands/config/set/luis.test.ts b/packages/config/test/commands/config/set/luis.test.ts index 9b381e9a5..5d552414a 100644 --- a/packages/config/test/commands/config/set/luis.test.ts +++ b/packages/config/test/commands/config/set/luis.test.ts @@ -14,6 +14,7 @@ describe('config:set:luis', () => { test .stdout() .command(['config:set:luis', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Stores default LUIS application values in global config.') }) diff --git a/packages/config/test/commands/config/set/qnamaker.test.ts b/packages/config/test/commands/config/set/qnamaker.test.ts index 492b4eba5..fbada3a12 100644 --- a/packages/config/test/commands/config/set/qnamaker.test.ts +++ b/packages/config/test/commands/config/set/qnamaker.test.ts @@ -46,6 +46,7 @@ describe('config:set:qnamaker', () => { test .stdout() .command(['config:set:qnamaker']) + .exit(1) .it('Asks for a flag', ctx => { expect(ctx.stdout).to.contain('Plase specify flag') }) diff --git a/packages/config/test/commands/config/set/telemetry.test.ts b/packages/config/test/commands/config/set/telemetry.test.ts index d7463203e..d3c54a2e1 100644 --- a/packages/config/test/commands/config/set/telemetry.test.ts +++ b/packages/config/test/commands/config/set/telemetry.test.ts @@ -1,4 +1,5 @@ import {expect, test} from '@oclif/test' +import { exit } from 'process' import {initTestConfigFile, deleteTestConfigFile, getConfigFile} from './../../../configfilehelper' const fs = require('fs-extra') @@ -23,6 +24,7 @@ describe('config:set:telemetry', () => { test .stdout() .command(['config:set:telemetry']) + .exit(1) .it('Shows help and keeps the same seetings', async ctx => { let config = await fs.readJSON(getConfigFile()) expect(config.telemetry).to.be.true diff --git a/packages/luis/test/commands/luis/application/create.test.ts b/packages/luis/test/commands/luis/application/create.test.ts index 0e55a5187..ecf909eb9 100644 --- a/packages/luis/test/commands/luis/application/create.test.ts +++ b/packages/luis/test/commands/luis/application/create.test.ts @@ -18,6 +18,7 @@ describe('luis:application:create', () => { test .stdout() .command(['luis:application:create', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Creates a new LUIS application') }) @@ -26,6 +27,7 @@ describe('luis:application:create', () => { .stdout() .stderr() .command(['luis:application:create', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1(), '--culture', 'en-us', '--description', 'test description', '--versionId', '0.04']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'name' missing.`) }) @@ -34,6 +36,7 @@ describe('luis:application:create', () => { .stdout() .stderr() .command(['luis:application:create', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--name', 'orange_app', '--culture', 'en-us', '--description', 'test description', '--versionId', '0.04']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -54,6 +57,7 @@ describe('luis:application:create', () => { .stdout() .stderr() .command(['luis:application:create', '--endpoint', 'undefined', '--name', 'orange_app', '--subscriptionKey', uuidv1(), '--culture', 'en-us', '--description', 'test description', '--versionId', '0.04']) + .exit(1) .it('fails to create an app and displays an error message if the endpoint is undefined', ctx => { expect(ctx.stderr).to.contain('Failed to create app: TypeError: Only absolute URLs are supported\n') }) diff --git a/packages/luis/test/commands/luis/application/delete.test.ts b/packages/luis/test/commands/luis/application/delete.test.ts index a39b92f80..9eece7ed0 100644 --- a/packages/luis/test/commands/luis/application/delete.test.ts +++ b/packages/luis/test/commands/luis/application/delete.test.ts @@ -16,6 +16,7 @@ describe('luis:application:delete', () => { test .stdout() .command(['luis:application:delete', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Deletes a LUIS application') }) @@ -24,6 +25,7 @@ describe('luis:application:delete', () => { .stdout() .stderr() .command(['luis:application:delete', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'appId' missing.`) }) @@ -32,6 +34,7 @@ describe('luis:application:delete', () => { .stdout() .stderr() .command(['luis:application:delete', '--appId', uuidv1(), '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'endpoint' missing.`) }) @@ -51,6 +54,7 @@ describe('luis:application:delete', () => { .stdout() .stderr() .command(['luis:application:delete', '--appId', uuidv1(), '--endpoint', 'undefined', '--subscriptionKey', uuidv1(), '--force']) + .exit(1) .it('fails to delete an app and displays an error message if the endpoint is undefined', ctx => { expect(ctx.stderr).to.contain('Failed to delete app') }) diff --git a/packages/luis/test/commands/luis/application/import.test.ts b/packages/luis/test/commands/luis/application/import.test.ts index f6ce92aa4..3abf5b482 100644 --- a/packages/luis/test/commands/luis/application/import.test.ts +++ b/packages/luis/test/commands/luis/application/import.test.ts @@ -17,6 +17,7 @@ describe('luis:application:import', () => { test .stdout() .command(['luis:application:import', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Imports LUIS application from JSON or LU content.') }) @@ -25,6 +26,7 @@ describe('luis:application:import', () => { .stdout() .stderr() .command(['luis:application:import', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--name', 'sample_app']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -45,6 +47,7 @@ describe('luis:application:import', () => { .stdout() .stderr() .command(['luis:application:import', '--name', 'Sample', '--in', './test/fixtures/xyz.json', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error message if the import file cannot be found', ctx => { expect(ctx.stderr).to.contain('Failed to read app JSON') }) @@ -53,6 +56,7 @@ describe('luis:application:import', () => { .stdout() .stderr() .command(['luis:application:import', '--name', 'Sample', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error message if no input data detected', ctx => { expect(ctx.stderr).to.contain('No import data found - please provide input through stdin or the --in flag') }) @@ -62,6 +66,7 @@ describe('luis:application:import', () => { .stdout() .stderr() .command(['luis:application:import', '--name', 'sampleapp', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('imports a luis app from stdin and returns the app\'s id', ctx => { process.stdin.setEncoding('utf8') process.stdin.once('data', data => { diff --git a/packages/luis/test/commands/luis/application/list.test.ts b/packages/luis/test/commands/luis/application/list.test.ts index 2688131f1..e181d04fa 100644 --- a/packages/luis/test/commands/luis/application/list.test.ts +++ b/packages/luis/test/commands/luis/application/list.test.ts @@ -29,6 +29,7 @@ describe('luis:application:list', () => { test .stdout() .command(['luis:application:list', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Lists all applications on LUIS service.') }) @@ -37,6 +38,7 @@ describe('luis:application:list', () => { .stdout() .stderr() .command(['luis:application:list', '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -72,6 +74,7 @@ describe('luis:application:list', () => { .stdout() .stderr() .command(['luis:application:list', '--out', 'xyz', '--subscriptionKey', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays a list of applications and a success message in the console (since the target path provided is invalid)', ctx => { expect(ctx.stderr).to.contain('Target directory path doesn\'t exist:') }) diff --git a/packages/luis/test/commands/luis/application/publish.test.ts b/packages/luis/test/commands/luis/application/publish.test.ts index ec64134ce..61db41022 100644 --- a/packages/luis/test/commands/luis/application/publish.test.ts +++ b/packages/luis/test/commands/luis/application/publish.test.ts @@ -20,6 +20,7 @@ describe('luis:application:publish', () => { test .stdout() .command(['luis:application:publish', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Publishes application\'s version') }) @@ -28,6 +29,7 @@ describe('luis:application:publish', () => { .stdout() .stderr() .command(['luis:application:publish', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1(), '--appId', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'versionId' missing.`) }) @@ -36,6 +38,7 @@ describe('luis:application:publish', () => { .stdout() .stderr() .command(['luis:application:publish', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1(), '--versionId', '0.01']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) diff --git a/packages/luis/test/commands/luis/application/query.test.ts b/packages/luis/test/commands/luis/application/query.test.ts index 2e4e60a86..8ee893f6c 100644 --- a/packages/luis/test/commands/luis/application/query.test.ts +++ b/packages/luis/test/commands/luis/application/query.test.ts @@ -20,6 +20,7 @@ describe('luis:application:query', () => { test .stdout() .command(['luis:application:query', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Queries application for intent predictions') }) @@ -28,6 +29,7 @@ describe('luis:application:query', () => { .stdout() .stderr() .command(['luis:application:query', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1(), '--staging', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'query' missing.`) }) @@ -36,6 +38,7 @@ describe('luis:application:query', () => { .stdout() .stderr() .command(['luis:application:query', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1(), '--staging', '--query', 'test query']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'appId' missing.`) }) @@ -62,6 +65,7 @@ describe('luis:application:query', () => { .stdout() .stderr() .command(['luis:application:query', '--endpoint', 'undefined', '--appId', uuidv1(), '--subscriptionKey', uuidv1(), '--staging', '--query', 'test query']) + .exit(1) .it('fails to query app and displays an error message if the endpoint is null', ctx => { expect(ctx.stderr).to.contain('Failed to fetch prediction data') }) diff --git a/packages/luis/test/commands/luis/application/rename.test.ts b/packages/luis/test/commands/luis/application/rename.test.ts index 66710c4f1..b37d4f94e 100644 --- a/packages/luis/test/commands/luis/application/rename.test.ts +++ b/packages/luis/test/commands/luis/application/rename.test.ts @@ -20,6 +20,7 @@ describe('luis:application:rename', () => { test .stdout() .command(['luis:application:rename', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Renames the application and updates its description') }) @@ -28,6 +29,7 @@ describe('luis:application:rename', () => { .stdout() .stderr() .command(['luis:application:rename', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1(), '--subscriptionKey', uuidv1(), '--description', 'test description']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing required flag:') expect(ctx.stderr).to.contain('--name NAME') @@ -37,6 +39,7 @@ describe('luis:application:rename', () => { .stdout() .stderr() .command(['luis:application:rename', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1(), '--name', 'sample-app', '--description', 'test description']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -57,6 +60,7 @@ describe('luis:application:rename', () => { .stdout() .stderr() .command(['luis:application:rename', '--endpoint', 'undefined', '--subscriptionKey', uuidv1(), '--appId', uuidv1(), '--name', 'sample-app', '--description', 'test description']) + .exit(1) .it('fails to create an app and displays an error message if the endpoint is undefined', ctx => { expect(ctx.stderr).to.contain('Failed to rename app: TypeError: Only absolute URLs are supported\n') }) diff --git a/packages/luis/test/commands/luis/application/show.test.ts b/packages/luis/test/commands/luis/application/show.test.ts index 9dae921cb..92a405049 100644 --- a/packages/luis/test/commands/luis/application/show.test.ts +++ b/packages/luis/test/commands/luis/application/show.test.ts @@ -17,6 +17,7 @@ describe('luis:application:show', () => { test .stdout() .command(['luis:application:show', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Shows application information') }) @@ -25,6 +26,7 @@ describe('luis:application:show', () => { .stdout() .stderr() .command(['luis:application:show', '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) diff --git a/packages/luis/test/commands/luis/convert.test.ts b/packages/luis/test/commands/luis/convert.test.ts index c30bbf6dc..7af1f0ea8 100644 --- a/packages/luis/test/commands/luis/convert.test.ts +++ b/packages/luis/test/commands/luis/convert.test.ts @@ -94,6 +94,7 @@ describe('luis:convert', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid-entity-definition.lu')}`]) + .exit(1) .it('luis:convert writes out an error when invalid entity definition is found', async (ctx: any) => { expect(ctx.stderr).to.contain("Invalid entity line, did you miss entity type after $\n") }) @@ -108,6 +109,7 @@ describe('luis:convert', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/utterance-without-hyphen.lu')}`]) + .exit(1) .it('luis:convert writes out an error when utterance without hyphen is found', async (ctx: any) => { expect(ctx.stderr).to.contain("[ERROR] line 2:0 - line 2:16: Invalid intent body line, did you miss '-' at line begin") expect(ctx.stderr).to.contain("[ERROR] line 6:0 - line 6:16: Invalid intent body line, did you miss '-' at line begin") @@ -116,6 +118,7 @@ describe('luis:convert', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/list-entity-body-without-hyphen.lu')}`]) + .exit(1) .it('luis:convert writes out an error when list entity body without hyphen is found', async (ctx: any) => { expect(ctx.stderr).to.contain("[ERROR] line 5:0 - line 5:2: Invalid list entity line, did you miss '-' at line begin") expect(ctx.stderr).to.contain("[ERROR] line 8:0 - line 8:2: Invalid list entity line, did you miss '-' at line begin") @@ -124,6 +127,7 @@ describe('luis:convert', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/qna-question-line-without-hyphen.lu')}`]) + .exit(1) .it('luis:convert writes out an error when list qna question line without hyphen is found', async (ctx: any) => { expect(ctx.stderr).to.contain("[ERROR] line 2:0 - line 2:10: Invalid QnA question line, did you miss '-' at line begin") }) @@ -131,6 +135,7 @@ describe('luis:convert', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/qna-filter-line-without-hyphen.lu')}`]) + .exit(1) .it('luis:convert writes out an error when list qna filter line without hyphen is found', async (ctx: any) => { expect(ctx.stderr).to.contain("[ERROR] line 6:0 - line 6:16: Invalid QnA filter line, did you miss '-' at line begin") }) @@ -304,6 +309,7 @@ describe('luis:convert', () => { .stdout() .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid_prebuilt_2.lu')}`]) + .exit(1) .it('luis:convert Invalid entity inherits information is skipped (prebuilt 2)', async (ctx: any) => { expect(ctx.stdout).to.contain(`Skipping "> !# @entity.inherits = name : Web.WebSearch"`) expect(ctx.stderr).to.contain('No LU or Luis content parsed!') @@ -313,6 +319,7 @@ describe('luis:convert', () => { .stdout() .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid_prebuilt_1.lu')}`]) + .exit(1) .it('luis:convert Invalid intent inherits information is skipped (prebuilt 1)', async (ctx: any) => { expect(ctx.stdout).to.contain(`Skipping "> !# @intent.inherits = name : Web.WebSearch"`) expect(ctx.stderr).to.contain('No LU or Luis content parsed!') @@ -322,6 +329,7 @@ describe('luis:convert', () => { .stdout() .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid_prebuilt_3.lu')}`, '--log']) + .exit(1) .it('luis:convert Invalid entity inherits information is skipped (prebuilt 3)', async (ctx: any) => { expect(ctx.stdout).to.contain(`Skipping "> !# @entity.inherits2 = name : Web.WebSearch"`) expect(ctx.stderr).to.contain('No LU or Luis content parsed!') @@ -331,6 +339,7 @@ describe('luis:convert', () => { .stdout() .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid_prebuilt_4.lu')}`, '--log']) + .exit(1) .it('luis:convert Invalid intent inherits information is skipped (prebuilt 4)', async (ctx: any) => { expect(ctx.stdout).to.contain(`Skipping "> !# @intent.inherits2 = name : Web.WebSearch"`) expect(ctx.stderr).to.contain('No LU or Luis content parsed!') @@ -340,6 +349,7 @@ describe('luis:convert', () => { .stdout() .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid_model.lu')}`, '--log']) + .exit(1) .it('luis:convert Invalid intent inherits information is skipped (invalid model)', async (ctx: any) => { expect(ctx.stdout).to.contain(`Skipping "> !# @app = test"`) expect(ctx.stderr).to.contain('No LU or Luis content parsed!') @@ -450,6 +460,7 @@ describe('luis:convert file creation', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/newEntity1.json')}`, '--out', './newfolder/newEntity.lu']) + .exit(1) .it('luis:convert throws error if path to write doesnt exist', async (ctx: any) => { expect(ctx.stderr).to.contain('Path not found:') }) @@ -459,6 +470,7 @@ describe('luis:convert empty file handling', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/empty.lu')}`]) + .exit(1) .it('luis:convert errors out on empty lu file', async (ctx: any) => { expect(ctx.stderr).to.contain('[ERROR] Cannot parse empty') }) @@ -466,6 +478,7 @@ describe('luis:convert empty file handling', () => { test .stderr() .command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/empty.json')}`]) + .exit(1) .it('luis:convert errors out on empty json file', async (ctx: any) => { expect(ctx.stderr).to.contain('Sorry, error parsing content as Luis JSON\n') }) diff --git a/packages/luis/test/commands/luis/crossTrain.test.ts b/packages/luis/test/commands/luis/crossTrain.test.ts index 6e4ed9fde..58172610b 100644 --- a/packages/luis/test/commands/luis/crossTrain.test.ts +++ b/packages/luis/test/commands/luis/crossTrain.test.ts @@ -15,6 +15,7 @@ describe('luis:cross-train tests for cli parameters', () => { .stdout() .stderr() .command(['luis:cross-train']) + .exit(1) .it('displays an error if --in is not provided', ctx => { expect(ctx.stderr).to.contain('Missing input. Please specify a folder with --in flag') }) @@ -23,6 +24,7 @@ describe('luis:cross-train tests for cli parameters', () => { .stdout() .stderr() .command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interruption')}`]) + .exit(1) .it('displays an error if config is not provided', ctx => { expect(ctx.stderr).to.contain('Missing cross train config. Please provide config by --config or automatically construct config with --rootDialog.') }) diff --git a/packages/luis/test/commands/luis/endpoints/list.test.ts b/packages/luis/test/commands/luis/endpoints/list.test.ts index 8f8eb74ea..b28c79f49 100644 --- a/packages/luis/test/commands/luis/endpoints/list.test.ts +++ b/packages/luis/test/commands/luis/endpoints/list.test.ts @@ -29,6 +29,7 @@ describe('luis:endpoints:list', () => { test .stdout() .command(['luis:endpoints:list', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Returns available deployment endpoints') }) @@ -37,6 +38,7 @@ describe('luis:endpoints:list', () => { .stdout() .stderr() .command(['luis:endpoints:list', '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -72,6 +74,7 @@ describe('luis:endpoints:list', () => { .stdout() .stderr() .command(['luis:endpoints:list', '--appId', uuidv1(), '--out', 'xyz', '--subscriptionKey', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays a list of endpoints and a success message in the console (since the target path provided is invalid)', ctx => { expect(ctx.stderr).to.contain('Target directory path doesn\'t exist:') }) diff --git a/packages/luis/test/commands/luis/generate/cs.test.ts b/packages/luis/test/commands/luis/generate/cs.test.ts index fd2aded53..d53eea9a6 100644 --- a/packages/luis/test/commands/luis/generate/cs.test.ts +++ b/packages/luis/test/commands/luis/generate/cs.test.ts @@ -114,6 +114,7 @@ describe('luis:generate:cs', () => { `${path.join(__dirname, '../../../fixtures/generate/invalid.json')}`, '--out', `${path.join(__dirname, '../../../fixtures/generate/results/invalid.cs')}`]) + .exit(1) .it('Throws expected error if invalid JSON', async ctx => { expect(ctx.stderr).to.include('Invalid LUIS JSON file content.') }) diff --git a/packages/luis/test/commands/luis/generate/ts.test.ts b/packages/luis/test/commands/luis/generate/ts.test.ts index 0ec3863da..e3919d1bc 100644 --- a/packages/luis/test/commands/luis/generate/ts.test.ts +++ b/packages/luis/test/commands/luis/generate/ts.test.ts @@ -126,6 +126,7 @@ describe('luis:generate:ts', () => { `${path.join(__dirname, '../../../fixtures/generate/invalid.json')}`, '--out', `${path.join(__dirname, '../../../fixtures/generate/results/invalid.ts')}`]) + .exit(1) .it('Throws expected error if invalid JSON', async ctx => { expect(ctx.stderr).to.include('Invalid LUIS JSON file content.') }) diff --git a/packages/luis/test/commands/luis/index.test.ts b/packages/luis/test/commands/luis/index.test.ts index 762e7c342..6e2dcf6cc 100644 --- a/packages/luis/test/commands/luis/index.test.ts +++ b/packages/luis/test/commands/luis/index.test.ts @@ -5,6 +5,7 @@ describe('luis:index', () => { test .stdout() .command(['luis', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Manages LUIS assets on service and/or locally.') }) diff --git a/packages/luis/test/commands/luis/test.test.ts b/packages/luis/test/commands/luis/test.test.ts index 5aeef7969..efc0e8b10 100644 --- a/packages/luis/test/commands/luis/test.test.ts +++ b/packages/luis/test/commands/luis/test.test.ts @@ -18,6 +18,7 @@ describe('luis:test cli parameters test', () => { test .stdout() .command(['luis:test', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Test a .lu file or LUIS application JSON model against a published LUIS model') }) diff --git a/packages/luis/test/commands/luis/train/run.test.ts b/packages/luis/test/commands/luis/train/run.test.ts index c03852b26..93d70615e 100644 --- a/packages/luis/test/commands/luis/train/run.test.ts +++ b/packages/luis/test/commands/luis/train/run.test.ts @@ -17,6 +17,7 @@ describe('luis:train:run', () => { test .stdout() .command(['luis:train:run', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Issues asynchronous training request for LUIS application') }) diff --git a/packages/luis/test/commands/luis/train/show.test.ts b/packages/luis/test/commands/luis/train/show.test.ts index 62e577380..700b28cbf 100644 --- a/packages/luis/test/commands/luis/train/show.test.ts +++ b/packages/luis/test/commands/luis/train/show.test.ts @@ -17,6 +17,7 @@ describe('luis:train:show', () => { test .stdout() .command(['luis:train:show', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Shows training status') }) @@ -25,6 +26,7 @@ describe('luis:train:show', () => { .stdout() .stderr() .command(['luis:train:show', '--appId', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--versionId', '0.1']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) diff --git a/packages/luis/test/commands/luis/version/clone.test.ts b/packages/luis/test/commands/luis/version/clone.test.ts index 05ce63ee8..06ee68da7 100644 --- a/packages/luis/test/commands/luis/version/clone.test.ts +++ b/packages/luis/test/commands/luis/version/clone.test.ts @@ -16,6 +16,7 @@ describe('luis:version:clone', () => { test .stdout() .command(['luis:version:clone', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', (ctx: any) => { expect(ctx.stdout).to.contain('Creates a new version equivalent to the current snapshot of the selected application version.') }) @@ -24,6 +25,7 @@ describe('luis:version:clone', () => { .stdout() .stderr() .command(['luis:version:clone', '--versionId', '0.1', '--targetVersionId', '0.2', '--subscriptionKey', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', (ctx: any) => { expect(ctx.stderr).to.contain(`Required input property 'appId' missing.`) }) @@ -32,6 +34,7 @@ describe('luis:version:clone', () => { .stdout() .stderr() .command(['luis:version:clone', '--appId', uuidv1(), '--versionId', '0.1', '--targetVersionId', '0.2', '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', (ctx: any) => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) diff --git a/packages/luis/test/commands/luis/version/delete.test.ts b/packages/luis/test/commands/luis/version/delete.test.ts index 1e3d72183..e08235e37 100644 --- a/packages/luis/test/commands/luis/version/delete.test.ts +++ b/packages/luis/test/commands/luis/version/delete.test.ts @@ -16,6 +16,7 @@ describe('luis:version:delete', () => { test .stdout() .command(['luis:version:delete', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Deletes a LUIS application version') }) @@ -24,6 +25,7 @@ describe('luis:version:delete', () => { .stdout() .stderr() .command(['luis:version:delete', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'appId' missing.`) }) @@ -32,6 +34,7 @@ describe('luis:version:delete', () => { .stdout() .stderr() .command(['luis:version:delete', '--appId', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'versionId' missing.`) }) @@ -51,6 +54,7 @@ describe('luis:version:delete', () => { .stdout() .stderr() .command(['luis:version:delete', '--appId', uuidv1(), '--versionId', '0.2', '--endpoint', 'undefined', '--subscriptionKey', uuidv1()]) + .exit(1) .it('fails to delete an app and displays an error message if the endpoint is undefined', ctx => { expect(ctx.stderr).to.contain('Failed to delete app version') }) diff --git a/packages/luis/test/commands/luis/version/export.test.ts b/packages/luis/test/commands/luis/version/export.test.ts index 782aed6c1..6e68262cf 100644 --- a/packages/luis/test/commands/luis/version/export.test.ts +++ b/packages/luis/test/commands/luis/version/export.test.ts @@ -29,6 +29,7 @@ describe('luis:version:export', () => { test .stdout() .command(['luis:version:export', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Exports a LUIS application to JSON format') }) @@ -37,6 +38,7 @@ describe('luis:version:export', () => { .stdout() .stderr() .command(['luis:version:export', '--versionId', '0.1', '--subscriptionKey', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'appId' missing.`) }) @@ -45,6 +47,7 @@ describe('luis:version:export', () => { .stdout() .stderr() .command(['luis:version:export', '--appId', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'versionId' missing.`) }) @@ -86,6 +89,7 @@ describe('luis:version:export', () => { .stdout() .stderr() .command(['luis:version:export', '--appId', uuidv1(), '--out', 'xyz', '--versionId', '0.1', '--subscriptionKey', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('exports a luis app and displays a success message and the export contents in the console (since the target path provided is invalid)', ctx => { expect(ctx.stderr).to.contain('Target directory path doesn\'t exist:') }) diff --git a/packages/luis/test/commands/luis/version/import.test.ts b/packages/luis/test/commands/luis/version/import.test.ts index b5a0a18ea..4a2e6d8f0 100644 --- a/packages/luis/test/commands/luis/version/import.test.ts +++ b/packages/luis/test/commands/luis/version/import.test.ts @@ -17,6 +17,7 @@ describe('luis:version:import', () => { test .stdout() .command(['luis:version:import', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Imports a new version into a LUIS application from JSON or LU content.') }) @@ -25,6 +26,7 @@ describe('luis:version:import', () => { .stdout() .stderr() .command(['luis:version:import', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'appId' missing.`) }) @@ -33,6 +35,7 @@ describe('luis:version:import', () => { .stdout() .stderr() .command(['luis:version:import', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1()]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -65,6 +68,7 @@ describe('luis:version:import', () => { .stdout() .stderr() .command(['luis:version:import', '--appId', uuidv1(), '--in', './test/fixtures/xyz.json', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error message if the import file cannot be found', ctx => { expect(ctx.stderr).to.contain('Failed to read app JSON') }) @@ -73,6 +77,7 @@ describe('luis:version:import', () => { .stdout() .stderr() .command(['luis:version:import', '--appId', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('displays an error message if no input data detected', ctx => { expect(ctx.stderr).to.contain('No import data found - please provide input through stdin or the --in flag') }) @@ -82,6 +87,7 @@ describe('luis:version:import', () => { .stdout() .stderr() .command(['luis:version:import', '--appId', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--subscriptionKey', uuidv1()]) + .exit(1) .it('imports a luis app version from stdin and returns the app\'s id', ctx => { process.stdin.setEncoding('utf8') process.stdin.once('data', data => { diff --git a/packages/luis/test/commands/luis/version/list.test.ts b/packages/luis/test/commands/luis/version/list.test.ts index 006366104..2005fe94e 100644 --- a/packages/luis/test/commands/luis/version/list.test.ts +++ b/packages/luis/test/commands/luis/version/list.test.ts @@ -29,6 +29,7 @@ describe('luis:version:list', () => { test .stdout() .command(['luis:version:list', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Returns application\'s versions') }) @@ -37,6 +38,7 @@ describe('luis:version:list', () => { .stdout() .stderr() .command(['luis:version:list', '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -84,6 +86,7 @@ describe('luis:version:list', () => { .stdout() .stderr() .command(['luis:version:list', '--out', 'xyz', '--subscriptionKey', uuidv1(),'--appId', uuidv1(), '--endpoint', 'https://westus.api.cognitive.microsoft.com']) + .exit(1) .it('displays a list of application versions and a success message in the console (since the target path provided is invalid)', ctx => { expect(ctx.stderr).to.contain('Target directory path doesn\'t exist:') }) diff --git a/packages/luis/test/commands/luis/version/rename.test.ts b/packages/luis/test/commands/luis/version/rename.test.ts index 3df0387f4..e485a6cbd 100644 --- a/packages/luis/test/commands/luis/version/rename.test.ts +++ b/packages/luis/test/commands/luis/version/rename.test.ts @@ -16,6 +16,7 @@ describe('luis:version:rename', () => { test .stdout() .command(['luis:version:rename', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Renames application version') }) @@ -24,6 +25,7 @@ describe('luis:version:rename', () => { .stdout() .stderr() .command(['luis:version:rename', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1(), '--subscriptionKey', uuidv1(), '--newVersionId', '0.2']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'versionId' missing.`) }) @@ -32,6 +34,7 @@ describe('luis:version:rename', () => { .stdout() .stderr() .command(['luis:version:rename', '--endpoint', 'https://westus.api.cognitive.microsoft.com', '--appId', uuidv1(), '--versionId', '0.1', '--newVersionId', '0.2']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain(`Required input property 'subscriptionKey' missing.`) }) @@ -51,6 +54,7 @@ describe('luis:version:rename', () => { .stdout() .stderr() .command(['luis:version:rename', '--endpoint', 'undefined', '--subscriptionKey', uuidv1(), '--appId', uuidv1(), '--versionId', '0.1', '--newVersionId', '0.2']) + .exit(1) .it('fails to rename application version and displays an error message if the endpoint is undefined', ctx => { expect(ctx.stderr).to.contain('Failed to rename app version: TypeError: Only absolute URLs are supported\n') }) diff --git a/packages/plugins/test/commands/plugins/index.test.ts b/packages/plugins/test/commands/plugins/index.test.ts index 626399a8e..971289af9 100644 --- a/packages/plugins/test/commands/plugins/index.test.ts +++ b/packages/plugins/test/commands/plugins/index.test.ts @@ -5,6 +5,7 @@ describe('plugins:index', () => { .stdout() .stderr() .command(['plugins']) + .exit(1) .it('runs help', ctx => { expect(ctx.stdout).to.contain('Install, uninstall and show installed plugins') }) diff --git a/packages/plugins/test/commands/plugins/install.test.ts b/packages/plugins/test/commands/plugins/install.test.ts index bc26e8548..91db259ef 100644 --- a/packages/plugins/test/commands/plugins/install.test.ts +++ b/packages/plugins/test/commands/plugins/install.test.ts @@ -4,6 +4,7 @@ describe('plugins:install', () => { test .stderr() .command(['plugins:install', 'someplugin']) + .exit(1) .it('runs plugins:install someplugin', ctx => { expect(ctx.stderr).to.contain('someplugin is blacklisted') }) diff --git a/packages/plugins/test/commands/plugins/list.test.ts b/packages/plugins/test/commands/plugins/list.test.ts index ef44f8a9b..33b7e8042 100644 --- a/packages/plugins/test/commands/plugins/list.test.ts +++ b/packages/plugins/test/commands/plugins/list.test.ts @@ -4,6 +4,7 @@ describe('plugins:list', () => { test .stderr() .command(['plugins:list']) + .exit(1) .it('plugins:list', ctx => { expect(ctx.stderr).to.contain('no plugins installed\n') }) diff --git a/packages/plugins/test/commands/plugins/uninstall.test.ts b/packages/plugins/test/commands/plugins/uninstall.test.ts index 5ba82725a..98cc5d605 100644 --- a/packages/plugins/test/commands/plugins/uninstall.test.ts +++ b/packages/plugins/test/commands/plugins/uninstall.test.ts @@ -4,6 +4,7 @@ describe('plugins:uninstall', () => { test .stderr() .command(['plugins:uninstall', 'someplugin']) + .exit(1) .it('runs plugins:uninstall someplugin', ctx => { expect(ctx.stderr).to.contain('someplugin is not installed') }) diff --git a/packages/qnamaker/test/commands/qnamaker/alterations/replace.test.ts b/packages/qnamaker/test/commands/qnamaker/alterations/replace.test.ts index 3572ec6c4..ca9184d24 100644 --- a/packages/qnamaker/test/commands/qnamaker/alterations/replace.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/alterations/replace.test.ts @@ -26,6 +26,7 @@ describe('qnamaker:alterations:replace', () => { test .stderr() .command(['qnamaker:alterations:replace']) + .exit(1) .it('runs qnamaker:alterations:replace', ctx => { expect(ctx.stderr).to.contain('No input. Please set file path with --in or pipe required data to the command') }) diff --git a/packages/qnamaker/test/commands/qnamaker/build.test.ts b/packages/qnamaker/test/commands/qnamaker/build.test.ts index 92b0b56c4..8e824b7f9 100644 --- a/packages/qnamaker/test/commands/qnamaker/build.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/build.test.ts @@ -20,6 +20,7 @@ describe('qnamaker:build cli parameters test', () => { test .stdout() .command(['qnamaker:build', '--help']) + .exit(1) .it('should print the help contents when --help is passed as an argument', ctx => { expect(ctx.stdout).to.contain('Build .qna files to create or update qnamaker knowledge bases and qnamaker alterations') }) @@ -28,6 +29,7 @@ describe('qnamaker:build cli parameters test', () => { .stdout() .stderr() .command(['qnamaker:build', '--in', `${path.join(__dirname, './../../fixtures/testcases/qnabuild')}`, '--botName', 'Contoso']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing qnamaker subscription key. Please pass subscription key with --subscriptionKey flag or specify via bf config:set:qnamaker --subscriptionKey.') }) @@ -36,6 +38,7 @@ describe('qnamaker:build cli parameters test', () => { .stdout() .stderr() .command(['qnamaker:build', '--subscriptionKey', uuidv1(), '--botName', 'Contoso']) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing input. Please use stdin or pass a file or folder location with --in flag') }) @@ -44,6 +47,7 @@ describe('qnamaker:build cli parameters test', () => { .stdout() .stderr() .command(['qnamaker:build', '--subscriptionKey', uuidv1(), '--in', `${path.join(__dirname, './../../fixtures/testcases/qnabuild')}`]) + .exit(1) .it('displays an error if any required input parameters are missing', ctx => { expect(ctx.stderr).to.contain('Missing bot name. Please pass bot name with --botName flag or specify via --qnaConfig.') }) @@ -52,6 +56,7 @@ describe('qnamaker:build cli parameters test', () => { .stdout() .stderr() .command(['qnamaker:build', '--subscriptionKey', uuidv1(), '--in', `${path.join(__dirname, './../../fixtures/testcases/qnabuild')}`, '--botName', 'Contoso', '--dialog', 'cross-train']) + .exit(1) .it('displays an error if option specified by --dialog is not right', ctx => { expect(ctx.stderr).to.contain('Recognizer type specified by --dialog is not right. Please specify [multiLanguage|crosstrained]') }) diff --git a/packages/qnamaker/test/commands/qnamaker/convert.test.ts b/packages/qnamaker/test/commands/qnamaker/convert.test.ts index 8ceca4851..df1179344 100644 --- a/packages/qnamaker/test/commands/qnamaker/convert.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/convert.test.ts @@ -82,6 +82,7 @@ describe('qnamaker:convert', () => { test .stderr() .command(['qnamaker:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/invalid-alterations.lu')}`]) + .exit(1) .it('qnamaker:convert Throws when an invalid QnA Maker alteration is specified in the input .lu file', async (ctx) => { expect(ctx.stderr).to.contain("[ERROR] line 2:0 - line 2:13: Invalid list entity line, did you miss '-' at line begin") }) @@ -155,6 +156,7 @@ describe('qnamaker:convert file creation', () => { test .stderr() .command(['qnamaker:convert', '--in', `${path.join(__dirname, './../../fixtures/verified/all-qna.json')}`, '--out', '/testfolder/qna.lu']) + .exit(1) .it('qnamaker:convert refresh command successfully reconstructs a markdown file from QnA input file', async (ctx) => { expect(ctx.stderr).to.contain('Path not found:') }) @@ -164,6 +166,7 @@ describe('qnamaker:convert empty file handling', () => { test .stderr() .command(['qnamaker:convert', '--in', `${path.join(__dirname, './../../fixtures/empty.lu')}`]) + .exit(1) .it('qnamaker:convert errors out on empty lu file', async (ctx) => { expect(ctx.stderr).to.contain('[ERROR] Cannot parse empty') }) @@ -171,6 +174,7 @@ describe('qnamaker:convert empty file handling', () => { test .stderr() .command(['qnamaker:convert', '--in', `${path.join(__dirname, './../../fixtures/empty.json')}`]) + .exit(1) .it('qnamaker:convert errors out on empty json file', async (ctx) => { expect(ctx.stderr).to.contain('Sorry, error parsing content as QnA JSON\n') }) diff --git a/packages/qnamaker/test/commands/qnamaker/crossTrain.test.ts b/packages/qnamaker/test/commands/qnamaker/crossTrain.test.ts index ac62f91ec..ce3953c3f 100644 --- a/packages/qnamaker/test/commands/qnamaker/crossTrain.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/crossTrain.test.ts @@ -15,6 +15,7 @@ describe('qnamaker:cross-train tests for cli parameters', () => { .stdout() .stderr() .command(['qnamaker:cross-train']) + .exit(1) .it('displays an error if --in is not provided', ctx => { expect(ctx.stderr).to.contain('Missing input. Please specify a folder with --in flag') }) @@ -23,6 +24,7 @@ describe('qnamaker:cross-train tests for cli parameters', () => { .stdout() .stderr() .command(['qnamaker:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interruption')}`]) + .exit(1) .it('displays an error if config is not provided', ctx => { expect(ctx.stderr).to.contain('Missing cross train config. Please provide config by --config or automatically construct config with --rootDialog.') }) diff --git a/packages/qnamaker/test/commands/qnamaker/kb/create.test.ts b/packages/qnamaker/test/commands/qnamaker/kb/create.test.ts index 15a6ff884..5947939a2 100644 --- a/packages/qnamaker/test/commands/qnamaker/kb/create.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/kb/create.test.ts @@ -124,6 +124,7 @@ describe('qnamaker:kb:create No input', () => { test .stderr() .command(['qnamaker:kb:create']) + .exit(1) .it('Creates kb qnamaker:kb:create --in', ctx => { expect(ctx.stderr).to.contain('No input. Please set file path with --in or pipe required data to the command') }) diff --git a/packages/qnamaker/test/commands/qnamaker/kb/list.test.ts b/packages/qnamaker/test/commands/qnamaker/kb/list.test.ts index b0d6a2445..c77bb0935 100644 --- a/packages/qnamaker/test/commands/qnamaker/kb/list.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/kb/list.test.ts @@ -72,6 +72,7 @@ describe('qnamaker:kb:list', () => { test .stderr() .command(['qnamaker:kb:list']) + .exit(1) .it('Prompts the user if no config passed or set in config.file', ctx => { expect(ctx.stderr).to.contain('Did you run bf qnamaker:init yet?') }) diff --git a/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts b/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts index de8801dfc..31e9d46e3 100644 --- a/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts @@ -37,6 +37,7 @@ describe('qnamaker:kb:replace', () => { test .stderr() .command(['qnamaker:kb:replace']) + .exit(1) .it('runs qnamaker:kb:replace', ctx => { expect(ctx.stderr).to.contain('No input. Please set file path with --in or pipe required data to the command') }) diff --git a/packages/qnamaker/test/commands/qnamaker/kb/update.test.ts b/packages/qnamaker/test/commands/qnamaker/kb/update.test.ts index 809045933..96bb03f86 100644 --- a/packages/qnamaker/test/commands/qnamaker/kb/update.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/kb/update.test.ts @@ -48,6 +48,7 @@ describe('qnamaker:kb:update', () => { test .stderr() .command(['qnamaker:kb:update']) + .exit(1) .it('Updates knowledgebase no input', ctx => { expect(ctx.stderr).to.contain('No input. Please set file path with --in or pipe required data to the command') }) diff --git a/packages/qnamaker/test/commands/qnamaker/train.test.ts b/packages/qnamaker/test/commands/qnamaker/train.test.ts index 2689f4377..4d1c6250b 100644 --- a/packages/qnamaker/test/commands/qnamaker/train.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/train.test.ts @@ -4,6 +4,7 @@ describe('qnamaker:train', () => { test .stderr() .command(['qnamaker:train']) + .exit(1) .it('qnamaker:train no input passed', ctx => { expect(ctx.stderr).to.contain('No input. Please set file path with --in or pipe required data to the command') }) From f86a4a730f08d8ca54b496ad7ebd654e8ec68825 Mon Sep 17 00:00:00 2001 From: Fei Chen Date: Fri, 16 Oct 2020 16:27:01 +0800 Subject: [PATCH 4/6] fix test case --- packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts b/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts index 31e9d46e3..e9bbea124 100644 --- a/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/kb/replace.test.ts @@ -12,7 +12,7 @@ describe('qnamaker:kb:replace', () => { .reply(204) nock('https://westus.api.cognitive.microsoft.com/qnamaker/v4.0') - .put('/knowledgebases/287ce749-012c-4eed-a39c-e4f8f06616cf?qnaformat=true') + .put('/knowledgebases/287ce749-012c-4eed-a39c-e4f8f06616cf') .reply(204) }) From 378323c754fcf4420d983fc7cd8839147ade5cb1 Mon Sep 17 00:00:00 2001 From: Fei Chen Date: Fri, 16 Oct 2020 18:06:15 +0800 Subject: [PATCH 5/6] fix test --- .../qnamaker/test/commands/qnamaker/alterations/index.test.ts | 1 + .../qnamaker/test/commands/qnamaker/endpointkeys/index.test.ts | 1 + .../test/commands/qnamaker/endpointsettings/index.test.ts | 1 + packages/qnamaker/test/commands/qnamaker/kb/index.test.ts | 1 + .../test/commands/qnamaker/operationdetails/index.test.ts | 1 + 5 files changed, 5 insertions(+) diff --git a/packages/qnamaker/test/commands/qnamaker/alterations/index.test.ts b/packages/qnamaker/test/commands/qnamaker/alterations/index.test.ts index 852c792b8..89acb01d0 100644 --- a/packages/qnamaker/test/commands/qnamaker/alterations/index.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/alterations/index.test.ts @@ -4,6 +4,7 @@ describe('qnamaker:alterations:index', () => { test .stdout() .command(['qnamaker:alterations']) + .exit(1) .it('runs', ctx => { expect(ctx.stdout).to.contain('') }) diff --git a/packages/qnamaker/test/commands/qnamaker/endpointkeys/index.test.ts b/packages/qnamaker/test/commands/qnamaker/endpointkeys/index.test.ts index 1d4fa5439..5d094e8eb 100644 --- a/packages/qnamaker/test/commands/qnamaker/endpointkeys/index.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/endpointkeys/index.test.ts @@ -4,6 +4,7 @@ describe('qnamaker:endpointkeys:index', () => { test .stdout() .command(['qnamaker:endpointkeys']) + .exit(1) .it('runs', ctx => { expect(ctx.stdout).to.contain('') }) diff --git a/packages/qnamaker/test/commands/qnamaker/endpointsettings/index.test.ts b/packages/qnamaker/test/commands/qnamaker/endpointsettings/index.test.ts index 126ece164..069573844 100644 --- a/packages/qnamaker/test/commands/qnamaker/endpointsettings/index.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/endpointsettings/index.test.ts @@ -4,6 +4,7 @@ describe('qnamaker:endpointsettings:index', () => { test .stdout() .command(['qnamaker:endpointsettings']) + .exit(1) .it('runs', ctx => { expect(ctx.stdout).to.contain('') }) diff --git a/packages/qnamaker/test/commands/qnamaker/kb/index.test.ts b/packages/qnamaker/test/commands/qnamaker/kb/index.test.ts index 78ba26496..a26a88db1 100644 --- a/packages/qnamaker/test/commands/qnamaker/kb/index.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/kb/index.test.ts @@ -4,6 +4,7 @@ describe('qnamaker:kb:index', () => { test .stdout() .command(['qnamaker:kb']) + .exit(1) .it('runs', ctx => { expect(ctx.stdout).to.contain('') }) diff --git a/packages/qnamaker/test/commands/qnamaker/operationdetails/index.test.ts b/packages/qnamaker/test/commands/qnamaker/operationdetails/index.test.ts index db4b98ff7..97c52536f 100644 --- a/packages/qnamaker/test/commands/qnamaker/operationdetails/index.test.ts +++ b/packages/qnamaker/test/commands/qnamaker/operationdetails/index.test.ts @@ -4,6 +4,7 @@ describe('qnamaker:operationdetails:index', () => { test .stdout() .command(['qnamaker:operationdetails']) + .exit(1) .it('runs', ctx => { expect(ctx.stdout).to.contain('') }) From fadfe60e62cb5930225ecba286d4a080ca7ada49 Mon Sep 17 00:00:00 2001 From: Fei Chen Date: Mon, 19 Oct 2020 09:54:51 +0800 Subject: [PATCH 6/6] remove unused code --- packages/chatdown/test/commands/chatdown/convert.test.ts | 1 - packages/config/test/commands/config/set/telemetry.test.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/chatdown/test/commands/chatdown/convert.test.ts b/packages/chatdown/test/commands/chatdown/convert.test.ts index 697cdf6be..48caf6ef7 100644 --- a/packages/chatdown/test/commands/chatdown/convert.test.ts +++ b/packages/chatdown/test/commands/chatdown/convert.test.ts @@ -3,7 +3,6 @@ import assert from 'assert'; import fs from 'fs-extra'; import rimraf from 'rimraf'; import {expect, test} from '@oclif/test' -import { exit } from 'process'; const pkg = require('../../../package.json'); diff --git a/packages/config/test/commands/config/set/telemetry.test.ts b/packages/config/test/commands/config/set/telemetry.test.ts index d3c54a2e1..4c8399f9e 100644 --- a/packages/config/test/commands/config/set/telemetry.test.ts +++ b/packages/config/test/commands/config/set/telemetry.test.ts @@ -1,5 +1,4 @@ import {expect, test} from '@oclif/test' -import { exit } from 'process' import {initTestConfigFile, deleteTestConfigFile, getConfigFile} from './../../../configfilehelper' const fs = require('fs-extra')