Skip to content

Commit

Permalink
fix: default --test-level flag if --tests present
Browse files Browse the repository at this point in the history
  • Loading branch information
cbohlman committed Nov 10, 2023
1 parent a84313c commit 9d9e04d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export const ensuredDirFlag = Flags.custom<string>({
export const testLevelFlag = Flags.custom<TestLevel>({
char: 'l',
parse: (input) => Promise.resolve(input as TestLevel),
// eslint-disable-next-line @typescript-eslint/require-await
default: async (context) => {
if (context.flags.tests) return TestLevel.RunSpecifiedTests;
},
options: Object.values(TestLevel),
});

Expand All @@ -91,7 +95,6 @@ export const zipFileFlag = Flags.custom<string>({
export const testsFlag = Flags.string({
char: 't',
multiple: true,
dependsOn: ['test-level'],
summary: commonFlagMessages.getMessage('flags.tests.summary'),
description: commonFlagMessages.getMessage('flags.tests.description'),
// the old version allowed comma separated values, and the change is confusing enough to deserve a warning
Expand Down
9 changes: 9 additions & 0 deletions test/nuts/seeds/deploy.metadata.test-level.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ context('deploy metadata --test-level NUTs [name: %REPO_NAME%]', () => {
});
await testkit.expect.specificApexTestsToBeRun(REPO.deploy.testLevel.specifiedTests);
});

it('should set --test-level flag to (RunSpecifiedTests) if --tests flag is included', async () => {
const packages = testkit.packageNames.map((p) => `--source-dir ${p}`).join(' ');
const tests = REPO.deploy.testLevel.specifiedTests.join(',');
await testkit.deploy({
args: `${packages} --tests ${tests}`,
});
await testkit.expect.specificApexTestsToBeRun(REPO.deploy.testLevel.specifiedTests);
});
});

describe('test result format', () => {
Expand Down

0 comments on commit 9d9e04d

Please sign in to comment.