From c578cd3893966cf4ccc94caaddd05a9e51daf351 Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Mon, 20 Mar 2023 15:50:24 -0400 Subject: [PATCH 1/7] fix: check readiness failure in validate and lint --- src/commands/analytics/template/lint.ts | 6 ++++++ src/commands/analytics/template/validate.ts | 6 ++++++ test/commands/template/lint.test.ts | 24 +++++++++++++++++++++ test/commands/template/validate.test.ts | 24 +++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/src/commands/analytics/template/lint.ts b/src/commands/analytics/template/lint.ts index 94df3298..a8f1b94b 100644 --- a/src/commands/analytics/template/lint.ts +++ b/src/commands/analytics/template/lint.ts @@ -60,6 +60,12 @@ export default class Lint extends SfdxCommand { ); } + // check if there is any readiness failure + const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); + if (didAnyReadinessTasksFail) { + process.exitCode = 1; + } + this.ux.table( tasks.map(task => { return { diff --git a/src/commands/analytics/template/validate.ts b/src/commands/analytics/template/validate.ts index 9edd1e37..7e024317 100644 --- a/src/commands/analytics/template/validate.ts +++ b/src/commands/analytics/template/validate.ts @@ -80,6 +80,12 @@ export default class Validate extends SfdxCommand { this.ux.styledHeader(colorize(messages.getMessage('tasksFound', [result.id]), chalk.blue)); } + // check if there is any readiness failure + const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); + if (didAnyReadinessTasksFail) { + process.exitCode = 1; + } + this.ux.table( tasks.map(task => { return { diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 6b2a5896..2ae03021 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -35,3 +35,27 @@ describe('analytics:template:lint', () => { expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); }); }); + +const templateWithFailedReadiness = [ + { + id: '0Nkxx000000000zCAA', + tasks: [ + { + label: 'EvaluateTemplateRequirement', + message: "Expected number of accounts don't match. Expected: 100, Actual: 0", + readinessStatus: 'Failed' + } + ] + } +]; + +describe('analytics:template:lint failure', () => { + test + .withOrg({ username: 'test@org.com' }, true) + .withConnectionRequest(() => Promise.resolve({ result: templateWithFailedReadiness })) + .stdout() + .command(['analytics:template:validate', '--templateid', ID]) + .it(`runs analytics:template:validate --templateid ${ID}`, ctx => { + expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); + }); +}); diff --git a/test/commands/template/validate.test.ts b/test/commands/template/validate.test.ts index 0c337404..e4ad351f 100644 --- a/test/commands/template/validate.test.ts +++ b/test/commands/template/validate.test.ts @@ -34,3 +34,27 @@ describe('analytics:template:validate', () => { expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); }); }); + +const templateWithFailedReadiness = [ + { + id: '0Nkxx000000000zCAA', + tasks: [ + { + label: 'EvaluateTemplateRequirement', + message: "Expected number of accounts don't match. Expected: 100, Actual: 0", + readinessStatus: 'Failed' + } + ] + } +]; + +describe('analytics:template:validate failure', () => { + test + .withOrg({ username: 'test@org.com' }, true) + .withConnectionRequest(() => Promise.resolve({ result: templateWithFailedReadiness })) + .stdout() + .command(['analytics:template:validate', '--templateid', ID]) + .it(`runs analytics:template:validate --templateid ${ID}`, ctx => { + expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); + }); +}); From 8330bcbdf88e68b2072a17cc839d7ddce725d29e Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Mon, 20 Mar 2023 17:21:58 -0400 Subject: [PATCH 2/7] fix: replace process.exitcode with sfdxerror --- src/commands/analytics/template/lint.ts | 14 +++++++------- src/commands/analytics/template/validate.ts | 12 ++++++------ test/commands/template/lint.test.ts | 1 + test/commands/template/validate.test.ts | 1 + 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/commands/analytics/template/lint.ts b/src/commands/analytics/template/lint.ts index a8f1b94b..7764ee32 100644 --- a/src/commands/analytics/template/lint.ts +++ b/src/commands/analytics/template/lint.ts @@ -6,7 +6,7 @@ */ import { flags, SfdxCommand } from '@salesforce/command'; -import { Org, Messages } from '@salesforce/core'; +import { Org, Messages, SfdxError } from '@salesforce/core'; import chalk from 'chalk'; import { colorize, getStatusIcon, COLORS } from '../../../lib/analytics/utils'; @@ -60,12 +60,6 @@ export default class Lint extends SfdxCommand { ); } - // check if there is any readiness failure - const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); - if (didAnyReadinessTasksFail) { - process.exitCode = 1; - } - this.ux.table( tasks.map(task => { return { @@ -87,6 +81,12 @@ export default class Lint extends SfdxCommand { } ); + // check if there is any readiness failure + const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); + if (didAnyReadinessTasksFail) { + throw new SfdxError('Template lint failed', undefined, undefined, 1, undefined); + } + return result; } } diff --git a/src/commands/analytics/template/validate.ts b/src/commands/analytics/template/validate.ts index 7e024317..0db00a6f 100644 --- a/src/commands/analytics/template/validate.ts +++ b/src/commands/analytics/template/validate.ts @@ -80,12 +80,6 @@ export default class Validate extends SfdxCommand { this.ux.styledHeader(colorize(messages.getMessage('tasksFound', [result.id]), chalk.blue)); } - // check if there is any readiness failure - const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); - if (didAnyReadinessTasksFail) { - process.exitCode = 1; - } - this.ux.table( tasks.map(task => { return { @@ -107,6 +101,12 @@ export default class Validate extends SfdxCommand { } ); + // check if there is any readiness failure + const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); + if (didAnyReadinessTasksFail) { + throw new SfdxError('Template validation failed', undefined, undefined, 1, undefined); + } + return result; } } diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 2ae03021..518ca281 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -55,6 +55,7 @@ describe('analytics:template:lint failure', () => { .withConnectionRequest(() => Promise.resolve({ result: templateWithFailedReadiness })) .stdout() .command(['analytics:template:validate', '--templateid', ID]) + // .exit(1) .it(`runs analytics:template:validate --templateid ${ID}`, ctx => { expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); }); diff --git a/test/commands/template/validate.test.ts b/test/commands/template/validate.test.ts index e4ad351f..c4e6a67c 100644 --- a/test/commands/template/validate.test.ts +++ b/test/commands/template/validate.test.ts @@ -54,6 +54,7 @@ describe('analytics:template:validate failure', () => { .withConnectionRequest(() => Promise.resolve({ result: templateWithFailedReadiness })) .stdout() .command(['analytics:template:validate', '--templateid', ID]) + // .exit(1) .it(`runs analytics:template:validate --templateid ${ID}`, ctx => { expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); }); From 6519e25a9f2abbecb3c9b919fb1f221b653856ef Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Wed, 22 Mar 2023 10:57:42 -0400 Subject: [PATCH 3/7] fix: tests are failing on exitcode check --- src/commands/analytics/template/lint.ts | 4 ++-- src/commands/analytics/template/validate.ts | 2 +- test/commands/template/lint.test.ts | 14 ++++++++------ test/commands/template/validate.test.ts | 15 +++++++++------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/commands/analytics/template/lint.ts b/src/commands/analytics/template/lint.ts index 7764ee32..d09fb8c7 100644 --- a/src/commands/analytics/template/lint.ts +++ b/src/commands/analytics/template/lint.ts @@ -6,7 +6,7 @@ */ import { flags, SfdxCommand } from '@salesforce/command'; -import { Org, Messages, SfdxError } from '@salesforce/core'; +import { Org, Messages } from '@salesforce/core'; import chalk from 'chalk'; import { colorize, getStatusIcon, COLORS } from '../../../lib/analytics/utils'; @@ -84,7 +84,7 @@ export default class Lint extends SfdxCommand { // check if there is any readiness failure const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); if (didAnyReadinessTasksFail) { - throw new SfdxError('Template lint failed', undefined, undefined, 1, undefined); + process.exitCode = 1; } return result; diff --git a/src/commands/analytics/template/validate.ts b/src/commands/analytics/template/validate.ts index 0db00a6f..55764b7a 100644 --- a/src/commands/analytics/template/validate.ts +++ b/src/commands/analytics/template/validate.ts @@ -104,7 +104,7 @@ export default class Validate extends SfdxCommand { // check if there is any readiness failure const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); if (didAnyReadinessTasksFail) { - throw new SfdxError('Template validation failed', undefined, undefined, 1, undefined); + process.exitCode = 1; } return result; diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 518ca281..57947f8d 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -50,13 +50,15 @@ const templateWithFailedReadiness = [ ]; describe('analytics:template:lint failure', () => { + const exitCode = process.exitCode; test .withOrg({ username: 'test@org.com' }, true) - .withConnectionRequest(() => Promise.resolve({ result: templateWithFailedReadiness })) - .stdout() - .command(['analytics:template:validate', '--templateid', ID]) - // .exit(1) - .it(`runs analytics:template:validate --templateid ${ID}`, ctx => { - expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); + .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) + .command(['analytics:template:lint', '--templateid', ID, '--apiversion', '58.0']) + .it(`runs analytics:template:lint --templateid ${ID}`, () => { + expect(process.exitCode).to.equal(1); }); + after(() => { + process.exitCode = exitCode; + }); }); diff --git a/test/commands/template/validate.test.ts b/test/commands/template/validate.test.ts index c4e6a67c..6fdf0e18 100644 --- a/test/commands/template/validate.test.ts +++ b/test/commands/template/validate.test.ts @@ -49,13 +49,16 @@ const templateWithFailedReadiness = [ ]; describe('analytics:template:validate failure', () => { + const exitCode = process.exitCode; test .withOrg({ username: 'test@org.com' }, true) - .withConnectionRequest(() => Promise.resolve({ result: templateWithFailedReadiness })) - .stdout() - .command(['analytics:template:validate', '--templateid', ID]) - // .exit(1) - .it(`runs analytics:template:validate --templateid ${ID}`, ctx => { - expect(ctx.stdout).to.contain('Command only available in api version 58.0 or later'); + .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) + .command(['analytics:template:validate', '--templateid', ID, '--apiversion', '58.0']) + .it(`runs analytics:template:validate --templateid ${ID}`, () => { + expect(process.exitCode).to.equal(1); }); + + after(() => { + process.exitCode = exitCode; + }); }); From 24ece7079d1ff407739f0352522e338ea76b2956 Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Wed, 22 Mar 2023 10:59:56 -0400 Subject: [PATCH 4/7] fix: comment out failing tests (exitcode check) --- test/commands/template/lint.test.ts | 50 ++++++++++++------------- test/commands/template/validate.test.ts | 50 ++++++++++++------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 57947f8d..8770d0b5 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -36,29 +36,29 @@ describe('analytics:template:lint', () => { }); }); -const templateWithFailedReadiness = [ - { - id: '0Nkxx000000000zCAA', - tasks: [ - { - label: 'EvaluateTemplateRequirement', - message: "Expected number of accounts don't match. Expected: 100, Actual: 0", - readinessStatus: 'Failed' - } - ] - } -]; +// const templateWithFailedReadiness = [ +// { +// id: '0Nkxx000000000zCAA', +// tasks: [ +// { +// label: 'EvaluateTemplateRequirement', +// message: "Expected number of accounts don't match. Expected: 100, Actual: 0", +// readinessStatus: 'Failed' +// } +// ] +// } +// ]; -describe('analytics:template:lint failure', () => { - const exitCode = process.exitCode; - test - .withOrg({ username: 'test@org.com' }, true) - .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) - .command(['analytics:template:lint', '--templateid', ID, '--apiversion', '58.0']) - .it(`runs analytics:template:lint --templateid ${ID}`, () => { - expect(process.exitCode).to.equal(1); - }); - after(() => { - process.exitCode = exitCode; - }); -}); +// describe('analytics:template:lint failure', () => { +// const exitCode = process.exitCode; +// test +// .withOrg({ username: 'test@org.com' }, true) +// .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) +// .command(['analytics:template:lint', '--templateid', ID, '--apiversion', '58.0']) +// .it(`runs analytics:template:lint --templateid ${ID}`, () => { +// expect(process.exitCode).to.equal(1); +// }); +// after(() => { +// process.exitCode = exitCode; +// }); +// }); diff --git a/test/commands/template/validate.test.ts b/test/commands/template/validate.test.ts index 6fdf0e18..ce3220c3 100644 --- a/test/commands/template/validate.test.ts +++ b/test/commands/template/validate.test.ts @@ -35,30 +35,30 @@ describe('analytics:template:validate', () => { }); }); -const templateWithFailedReadiness = [ - { - id: '0Nkxx000000000zCAA', - tasks: [ - { - label: 'EvaluateTemplateRequirement', - message: "Expected number of accounts don't match. Expected: 100, Actual: 0", - readinessStatus: 'Failed' - } - ] - } -]; +// const templateWithFailedReadiness = [ +// { +// id: '0Nkxx000000000zCAA', +// tasks: [ +// { +// label: 'EvaluateTemplateRequirement', +// message: "Expected number of accounts don't match. Expected: 100, Actual: 0", +// readinessStatus: 'Failed' +// } +// ] +// } +// ]; -describe('analytics:template:validate failure', () => { - const exitCode = process.exitCode; - test - .withOrg({ username: 'test@org.com' }, true) - .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) - .command(['analytics:template:validate', '--templateid', ID, '--apiversion', '58.0']) - .it(`runs analytics:template:validate --templateid ${ID}`, () => { - expect(process.exitCode).to.equal(1); - }); +// describe('analytics:template:validate failure', () => { +// const exitCode = process.exitCode; +// test +// .withOrg({ username: 'test@org.com' }, true) +// .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) +// .command(['analytics:template:validate', '--templateid', ID, '--apiversion', '58.0']) +// .it(`runs analytics:template:validate --templateid ${ID}`, () => { +// expect(process.exitCode).to.equal(1); +// }); - after(() => { - process.exitCode = exitCode; - }); -}); +// after(() => { +// process.exitCode = exitCode; +// }); +// }); From 391f60892499c77376dbe178745697b0342965e7 Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Wed, 22 Mar 2023 14:04:50 -0400 Subject: [PATCH 5/7] fix: fix dummy input in tests --- test/commands/template/lint.test.ts | 49 +++++++++-------- test/commands/template/validate.test.ts | 72 ++++++++++++------------- 2 files changed, 57 insertions(+), 64 deletions(-) diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 8770d0b5..1c8614c5 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -36,29 +36,28 @@ describe('analytics:template:lint', () => { }); }); -// const templateWithFailedReadiness = [ -// { -// id: '0Nkxx000000000zCAA', -// tasks: [ -// { -// label: 'EvaluateTemplateRequirement', -// message: "Expected number of accounts don't match. Expected: 100, Actual: 0", -// readinessStatus: 'Failed' -// } -// ] -// } -// ]; +const templateWithFailedReadiness = { + id: '0Nkxx000000000zCAA', + score: 85.6, + tasks: [ + { + label: 'EvaluateTemplateRequirement', + message: "Expected number of accounts don't match. Expected: 100, Actual: 0", + readinessStatus: 'Failed' + } + ] +}; -// describe('analytics:template:lint failure', () => { -// const exitCode = process.exitCode; -// test -// .withOrg({ username: 'test@org.com' }, true) -// .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) -// .command(['analytics:template:lint', '--templateid', ID, '--apiversion', '58.0']) -// .it(`runs analytics:template:lint --templateid ${ID}`, () => { -// expect(process.exitCode).to.equal(1); -// }); -// after(() => { -// process.exitCode = exitCode; -// }); -// }); +describe('analytics:template:lint failure', () => { + const exitCode = process.exitCode; + test + .withOrg({ username: 'test@org.com' }, true) + .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) + .command(['analytics:template:lint', '--templateid', ID, '--apiversion', '58.0']) + .it(`runs analytics:template:lint --templateid ${ID}`, () => { + expect(process.exitCode).to.equal(1); + }); + after(() => { + process.exitCode = exitCode; + }); +}); diff --git a/test/commands/template/validate.test.ts b/test/commands/template/validate.test.ts index ce3220c3..896946ce 100644 --- a/test/commands/template/validate.test.ts +++ b/test/commands/template/validate.test.ts @@ -11,19 +11,16 @@ import { expect, test } from '@salesforce/command/lib/test'; core.Messages.importMessagesDirectory(__dirname); // const messages = core.Messages.loadMessages('@salesforce/analytics', 'validate'); const ID = '0Nkxx000000000zCAA'; -const templateValues = [ - { - id: '0Nkxx000000000zCAA', - tasks: [ - { - label: 'TemplateAssociationTask', - message: 'Certification for sfdc_internal__Sales_Analytics_Flex template.', - readinessStatus: 'Complete' - } - ] - } -]; - +const templateValues = { + id: '0Nkxx000000000zCAA', + tasks: [ + { + label: 'TemplateAssociationTask', + message: 'Certification for sfdc_internal__Sales_Analytics_Flex template.', + readinessStatus: 'Complete' + } + ] +}; describe('analytics:template:validate', () => { test .withOrg({ username: 'test@org.com' }, true) @@ -35,30 +32,27 @@ describe('analytics:template:validate', () => { }); }); -// const templateWithFailedReadiness = [ -// { -// id: '0Nkxx000000000zCAA', -// tasks: [ -// { -// label: 'EvaluateTemplateRequirement', -// message: "Expected number of accounts don't match. Expected: 100, Actual: 0", -// readinessStatus: 'Failed' -// } -// ] -// } -// ]; - -// describe('analytics:template:validate failure', () => { -// const exitCode = process.exitCode; -// test -// .withOrg({ username: 'test@org.com' }, true) -// .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) -// .command(['analytics:template:validate', '--templateid', ID, '--apiversion', '58.0']) -// .it(`runs analytics:template:validate --templateid ${ID}`, () => { -// expect(process.exitCode).to.equal(1); -// }); +const templateWithFailedReadiness = { + id: '0Nkxx000000000zCAA', + tasks: [ + { + label: 'EvaluateTemplateRequirement', + message: "Expected number of accounts don't match. Expected: 100, Actual: 0", + readinessStatus: 'Failed' + } + ] +}; +describe('analytics:template:validate failure', () => { + const exitCode = process.exitCode; + test + .withOrg({ username: 'test@org.com' }, true) + .withConnectionRequest(() => Promise.resolve(templateWithFailedReadiness)) + .command(['analytics:template:validate', '--templateid', ID, '--apiversion', '58.0']) + .it(`runs analytics:template:validate --templateid ${ID}`, () => { + expect(process.exitCode).to.equal(1); + }); -// after(() => { -// process.exitCode = exitCode; -// }); -// }); + after(() => { + process.exitCode = exitCode; + }); +}); From 2581dc57b9ba0082f22ce0066878962a147d6cf9 Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Wed, 22 Mar 2023 14:53:35 -0400 Subject: [PATCH 6/7] fix: use sfdxerror in place of process.errcode --- src/commands/analytics/template/lint.ts | 4 ++-- src/commands/analytics/template/validate.ts | 2 +- test/commands/template/lint.test.ts | 24 ++++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/commands/analytics/template/lint.ts b/src/commands/analytics/template/lint.ts index d09fb8c7..d786808a 100644 --- a/src/commands/analytics/template/lint.ts +++ b/src/commands/analytics/template/lint.ts @@ -6,7 +6,7 @@ */ import { flags, SfdxCommand } from '@salesforce/command'; -import { Org, Messages } from '@salesforce/core'; +import { Org, Messages, SfdxError } from '@salesforce/core'; import chalk from 'chalk'; import { colorize, getStatusIcon, COLORS } from '../../../lib/analytics/utils'; @@ -84,7 +84,7 @@ export default class Lint extends SfdxCommand { // check if there is any readiness failure const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); if (didAnyReadinessTasksFail) { - process.exitCode = 1; + throw new SfdxError('Template linting failed', undefined, undefined, 1, undefined); } return result; diff --git a/src/commands/analytics/template/validate.ts b/src/commands/analytics/template/validate.ts index 55764b7a..0db00a6f 100644 --- a/src/commands/analytics/template/validate.ts +++ b/src/commands/analytics/template/validate.ts @@ -104,7 +104,7 @@ export default class Validate extends SfdxCommand { // check if there is any readiness failure const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); if (didAnyReadinessTasksFail) { - process.exitCode = 1; + throw new SfdxError('Template validation failed', undefined, undefined, 1, undefined); } return result; diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 1c8614c5..3ee4f748 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -11,19 +11,17 @@ import { expect, test } from '@salesforce/command/lib/test'; core.Messages.importMessagesDirectory(__dirname); // const messages = core.Messages.loadMessages('@salesforce/analytics', 'lint'); const ID = '0Nkxx000000000zCAA'; -const templateValues = [ - { - label: 'sfdc_internal__Sales_Analytics_Flex', - score: 85.6, - tasks: [ - { - label: 'TemplateAssociationTask', - message: 'Certification for sfdc_internal__Sales_Analytics_Flex template.', - readinessStatus: 'Complete' - } - ] - } -]; +const templateValues = { + label: 'sfdc_internal__Sales_Analytics_Flex', + score: 85.6, + tasks: [ + { + label: 'TemplateAssociationTask', + message: 'Certification for sfdc_internal__Sales_Analytics_Flex template.', + readinessStatus: 'Complete' + } + ] +}; describe('analytics:template:lint', () => { test From 04e75a2bce22a4d2a64cb2e0f12c720bcb1f967c Mon Sep 17 00:00:00 2001 From: Sanaz Arabzadeh Esfarjani Date: Thu, 23 Mar 2023 17:34:54 -0400 Subject: [PATCH 7/7] fix: pass in result as data to sfdxerror --- src/commands/analytics/template/lint.ts | 2 +- src/commands/analytics/template/validate.ts | 2 +- test/commands/template/lint.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/analytics/template/lint.ts b/src/commands/analytics/template/lint.ts index d786808a..75e9224c 100644 --- a/src/commands/analytics/template/lint.ts +++ b/src/commands/analytics/template/lint.ts @@ -84,7 +84,7 @@ export default class Lint extends SfdxCommand { // check if there is any readiness failure const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); if (didAnyReadinessTasksFail) { - throw new SfdxError('Template linting failed', undefined, undefined, 1, undefined); + throw new SfdxError('Template linting failed', undefined, undefined, 1, undefined).setData(result); } return result; diff --git a/src/commands/analytics/template/validate.ts b/src/commands/analytics/template/validate.ts index 0db00a6f..d090f252 100644 --- a/src/commands/analytics/template/validate.ts +++ b/src/commands/analytics/template/validate.ts @@ -104,7 +104,7 @@ export default class Validate extends SfdxCommand { // check if there is any readiness failure const didAnyReadinessTasksFail = tasks.some(task => task.readinessStatus === 'Failed'); if (didAnyReadinessTasksFail) { - throw new SfdxError('Template validation failed', undefined, undefined, 1, undefined); + throw new SfdxError('Template validation failed', undefined, undefined, 1, undefined).setData(result); } return result; diff --git a/test/commands/template/lint.test.ts b/test/commands/template/lint.test.ts index 3ee4f748..1b8d4d62 100644 --- a/test/commands/template/lint.test.ts +++ b/test/commands/template/lint.test.ts @@ -40,7 +40,7 @@ const templateWithFailedReadiness = { tasks: [ { label: 'EvaluateTemplateRequirement', - message: "Expected number of accounts don't match. Expected: 100, Actual: 0", + message: 'Certification for sfdc_internal__Sales_Analytics_Flex template.', readinessStatus: 'Failed' } ]